-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add home page to test site. Add autoload sandbox directory.
- Loading branch information
Showing
4 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
<?php | ||
|
||
print "Hello, world!"; | ||
use pjdietz\WellRESTed\Router; | ||
|
||
$loader = require_once __DIR__. "/../vendor/autoload.php"; | ||
$loader->addPsr4("", __DIR__ . "/../vagrant/src"); | ||
$loader->addPsr4("", __DIR__ . "/../autoload"); | ||
|
||
$router = new Router(); | ||
$router->add("/", "\\WellRESTedDev\\RootHandler"); | ||
$router->respond(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace WellRESTedDev; | ||
|
||
use pjdietz\WellRESTed\Interfaces\HandlerInterface; | ||
use pjdietz\WellRESTed\Interfaces\RequestInterface; | ||
use pjdietz\WellRESTed\Interfaces\ResponseInterface; | ||
use pjdietz\WellRESTed\Response; | ||
|
||
class RootHandler implements HandlerInterface | ||
{ | ||
/** | ||
* Return the handled response. | ||
* | ||
* @param RequestInterface $request The request to respond to. | ||
* @param array|null $args Optional additional arguments. | ||
* @return ResponseInterface The handled response. | ||
*/ | ||
public function getResponse(RequestInterface $request, array $args = null) | ||
{ | ||
$view = <<<HTML | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>WellRESTed</title> | ||
</head> | ||
<body> | ||
<h1>Welcome to the WellRESTed Test Site</h1> | ||
<ul> | ||
<li>View <a href="/docs/">Documentatation</a></li> | ||
<li>View <a href="/coverage/">Code Coverage Report</a></li> | ||
</ul> | ||
<p>Run <code>vagrant ssh</code>, then:</p> | ||
<dl> | ||
<dt>To run unit tests</dt> | ||
<dd><code>vendor/bin/phpunit</code></dd> | ||
<dt>To generate documentation</dt> | ||
<dd><code>make html -C docs</code></dd> | ||
</dl> | ||
<p>Use this site as a sandbox. Modify the router <code>/htdocs/index.php</code> however you like.</p> | ||
<p>Any classes you create inside <code>/autoload</code> will be autoloaded with a PSR-4 autoloader.</p> | ||
</body> | ||
</html> | ||
HTML; | ||
$response = new Response(200); | ||
$response->setBody($view); | ||
return $response; | ||
} | ||
} |