From a2f6bc1f22c7d0b8fe4b366ab7aeff859c8b3c4c Mon Sep 17 00:00:00 2001 From: PJ Dietz Date: Wed, 11 Mar 2015 21:32:09 -0400 Subject: [PATCH] Add home page to test site. Add autoload sandbox directory. --- .gitignore | 3 +- vagrant/index.php | 10 ++++- vagrant/provision.sh | 9 +++- vagrant/src/WellRESTedDev/RootHandler.php | 50 +++++++++++++++++++++++ 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 vagrant/src/WellRESTedDev/RootHandler.php diff --git a/.gitignore b/.gitignore index edbbb66..e4b6c18 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,6 @@ workspace.xml # Vagrant .vagrant/ -# Vagrant site's document root. +# Vagrant sandbox site files. /htdocs/ +/autoload/ diff --git a/vagrant/index.php b/vagrant/index.php index 7aa012a..a6bbc64 100644 --- a/vagrant/index.php +++ b/vagrant/index.php @@ -1,3 +1,11 @@ addPsr4("", __DIR__ . "/../vagrant/src"); +$loader->addPsr4("", __DIR__ . "/../autoload"); + +$router = new Router(); +$router->add("/", "\\WellRESTedDev\\RootHandler"); +$router->respond(); diff --git a/vagrant/provision.sh b/vagrant/provision.sh index 7107bfe..75cd8c1 100644 --- a/vagrant/provision.sh +++ b/vagrant/provision.sh @@ -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 -cp /vagrant/vagrant/index.php /vagrant/htdocs/index.php +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 diff --git a/vagrant/src/WellRESTedDev/RootHandler.php b/vagrant/src/WellRESTedDev/RootHandler.php new file mode 100644 index 0000000..1336d66 --- /dev/null +++ b/vagrant/src/WellRESTedDev/RootHandler.php @@ -0,0 +1,50 @@ + + + + + WellRESTed + + +

Welcome to the WellRESTed Test Site

+ +

Run vagrant ssh, then:

+
+
To run unit tests
+
vendor/bin/phpunit
+
To generate documentation
+
make html -C docs
+
+

Use this site as a sandbox. Modify the router /htdocs/index.php however you like.

+

Any classes you create inside /autoload will be autoloaded with a PSR-4 autoloader.

+ + +HTML; + $response = new Response(200); + $response->setBody($view); + return $response; + } +}