2017 © Pedro Peláez
 

library spawn-point

A featherweight dispatch process enabling rapid development.

image

smrtr/spawn-point

A featherweight dispatch process enabling rapid development.

  • Wednesday, November 11, 2015
  • by joegreen88
  • Repository
  • 3 Watchers
  • 0 Stars
  • 76 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

spawn-point

A quick and dirty dispatch process using Haltorouter., (*1)

This featherweight stack uses Symfony's HttpFoundation Request & Response objects with [Smrtr's Haltorouter][2] object to enable you to start developing extremely quickly., (*2)

Installation

From your project root:, (*3)

  1. Require spawn-point with composer. Add "smrtr/spawn-point": "~1.0" to the require section of your composer.json.
  2. Run composer update to download the spawn-point library.
  3. Run vendor/bin/spawn spawn to create the required project files.

Configuration

vHost

Apache2 vhost configuration must declare the rewrite engine to be on and the document root to be inside a directory called public inside your project root. See the following vhost for a project called Buzz located in /var/www/Buzz:, (*4)

# Buzz
<VirtualHost *:80>
    ServerName buzz.local
    ServerAlias www.buzz.local
    ServerAlias private.buzz.local
    DocumentRoot "/var/www/Buzz/public"
    RewriteEngine on
    SetEnv APP_ENV "development"
    <Directory "/var/www/Buzz/public">
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Satisfy Any
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>

Hostgroups

Use app/config/hostgroups.ini to organize hostnames into groups. These hostgroups are used to match requests. See the following hostgroup configuration for example which creates two groups, 'Public' and 'Private':, (*5)

[development]
Public[] = "buzz.local"
Public[] = "www.buzz.local"
Private[] = "private.buzz.local"

Routes

Use app/config/routes.ini to define your routes. These routes will be passed into a Smrtr\Haltorouter instance. Routes can be grouped by environment if you wish. See the following example which defines a route to the homepage across the development & production environments:, (*6)

[bootstrap]
homepage.route = "/"
homepage.method = "GET"
homepage.hostgroup = "Public"
homepage.target = "\Buzz\HomepageController@homepage"

[development : bootstrap]

[production : bootstrap]

The 'target' of the route tells the application which class to load and which method to call., (*7)

PHP settings

You may specify php settings, much like you would in php.ini, in app/config/phpSettings.ini. This is a convenient way to define php settings at runtime without depending on the php settings of the environment., (*8)

Usage

To complete our example we need to implement the homepage controller which we defined in our routes config., (*9)

In src\Buzz\HomepageController.php:, (*10)

<?php
namespace Buzz;
use Smrtr\SpawnPoint\AbstractController;

class HomepageController extends AbstractController
{
    public function homepage()
    {
        echo "hello world!";
    }
}

Request parameters

1. Add a parametrised route to your app/config/routes.ini:
user.route = "/user/[i:id]"
user.method = "GET"
user.hostgroup = "Public"
user.target = "\Buzz\UserController@user"
2. Retrieve the parameter from the request object in src/Buzz/UserController.php:
<?php
namespace Buzz;
use Smrtr\SpawnPoint\AbstractController;

class UserController extends AbstractController
{
    public function user()
    {
        $id = (int) $this->getRoutedParam('id');
    }
}

The Versions

11/11 2015

dev-master

9999999-dev

A featherweight dispatch process enabling rapid development.

  Sources   Download

MIT

The Requires

 

httpfoundation spawn haltorouter

11/11 2015

1.2.0

1.2.0.0

A featherweight dispatch process enabling rapid development.

  Sources   Download

MIT

The Requires

 

httpfoundation spawn haltorouter

10/11 2015

1.1.0

1.1.0.0

A featherweight dispatch process enabling rapid development.

  Sources   Download

MIT

The Requires

 

httpfoundation spawn haltorouter

07/03 2014

1.0.3

1.0.3.0

A featherweight dispatch process enabling rapid development.

  Sources   Download

MIT

The Requires

 

httpfoundation spawn haltorouter

18/02 2014

1.0.2

1.0.2.0

A featherweight dispatch process enabling rapid development.

  Sources   Download

MIT

The Requires

 

httpfoundation spawn haltorouter

18/02 2014

1.0.1

1.0.1.0

A featherweight dispatch process enabling rapid development.

  Sources   Download

MIT

The Requires

 

httpfoundation spawn haltorouter