Add home page to test site. Add autoload sandbox directory.
This commit is contained in:
parent
381310a88a
commit
a2f6bc1f22
|
|
@ -24,5 +24,6 @@ workspace.xml
|
|||
# Vagrant
|
||||
.vagrant/
|
||||
|
||||
# Vagrant site's document root.
|
||||
# Vagrant sandbox site files.
|
||||
/htdocs/
|
||||
/autoload/
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ fi
|
|||
|
||||
# Create the document and symlinks.
|
||||
if [ ! -d /vagrant/htdocs ] ; then
|
||||
mkdir /vagrant/htdocs 2&> /dev/null
|
||||
mkdir /vagrant/htdocs
|
||||
fi
|
||||
if [ ! -h /vagrant/htdocs/docs ] ; then
|
||||
ln -s /vagrant/docs/build/html /vagrant/htdocs/docs
|
||||
|
|
@ -49,7 +49,12 @@ fi
|
|||
if [ ! -h /vagrant/htdocs/coverage ] ; then
|
||||
ln -s /vagrant/report /vagrant/htdocs/coverage
|
||||
fi
|
||||
if [ ! -f /vagrant/htdocs/index.php ] ; then
|
||||
cp /vagrant/vagrant/index.php /vagrant/htdocs/index.php
|
||||
fi
|
||||
if [ ! -d /vagrant/autoload ] ; then
|
||||
mkdir /vagrant/autoload
|
||||
fi
|
||||
|
||||
# Install Composer dependencies
|
||||
composer --working-dir=/vagrant install
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue