dev-master
9999999-dev https://github.com/zapheus/skeletonAn application structure for Zapheus framework.
MIT
The Requires
- php >=5.3.0
- vlucas/phpdotenv ~2.0
- zapheus/zapheus ~0.1
The Development Requires
skeleton structure application zapheus
Wallogit.com
2017 © Pedro Peláez
An application structure for Zapheus framework.
![Latest Version on Packagist][ico-version]
![Coverage Status][ico-scrutinizer]
![Total Downloads][ico-downloads], (*1)
An application structure for Zapheus framework., (*2)
Install Skeleton via Composer:, (*3)
``` bash $ composer create-project zapheus/skeleton:dev-master "acme", (*4)
## Basic Usage ### Running the application Use PHP's built-in web server (available in v5.4+) ``` bash $ php -S localhost:8000 -t app/web
Now open your web browser and go to http://localhost:8000., (*5)
``` php // app/config/providers.php, (*6)
return array( // ..., (*7)
'zapheus' => array(
// ...
// Application Providers
'App\Acme\AcmeProvider',
'App\Acme\SampleProvider',
// ...
),
);, (*8)
A Zapheus provider must be implemented in a `ProviderInterface`: ``` php namespace Zapheus\Provider; use Zapheus\Container\WritableInterface; interface ProviderInterface { /** * @return \Zapheus\Container\ContainerInterface */ public function register(WritableInterface $container); }
MappingsProvider
``` php // src/Zapheus/MappingsProvider.php, (*9)
class MappingsProvider implements ProviderInterface { public function register(WritableInterface $container) { $test = 'App\Acme\DelegatesController';, (*10)
return $container->set($test, new $test); }
}, (*11)
`MappingsProvider` is only applicable for specified handling of dependencies because Zapheus will try to manage the dependencies based on instances found from the container by default. For complex dependencies, it is recommended to implement it into a `ProviderInterface` instead. ### Adding HTTP routes to `DispatcherProvider` ``` php // src/Acme/RouteCollection.php use Zapheus\Routing\Router; class RouteCollection extends Router { /** * Namespace applied to all class-based routes. * * @var string */ protected $namespace = 'App\Acme'; /** * Returns an array of route instances. * * @return \Zapheus\Routing\Route[] */ public function routes() { $this->get('/delegates', 'DelegatesController@index'); return $this->routes; } }
``` php // src/Zapheus/DispatcherProvider.php, (*12)
class DispatcherProvider implements ProviderInterface { /** * An array of Zapheus\Routing\RouterInterface instances. * * @var string[] */ protected $routers = array('App\Acme\RouteCollection');, (*13)
// ..
}, (*14)
### Adding multi-directory template files ``` php // src/Acme/AcmeProvider.php use Zapheus\Container\WritableInterface; use Zapheus\Provider\ProviderInterface; class AcmeProvider implements ProviderInterface { /** * Registers the bindings in the container. * * @param \Zapheus\Container\WritableInterface $container * @return \Zapheus\Container\ContainerInterface */ public function register(WritableInterface $container) { // ... $templates = __DIR__ . DIRECTORY_SEPARATOR . 'Templates'; // Add a dot notation after "app.views" $config->set('app.views.acme', $templates); // ... } }
``` php // src/Acme/DelegatesController, (*15)
class DelegatesController { protected $renderer;, (*16)
public function __construct(RendererInterface $renderer)
{
$this->renderer = $renderer;
}
public function index()
{
// Use the "acme" prefix defined from AcmeProvider
return $this->renderer->render('acme.test');
}
}, (*17)
## Changelog Please see [CHANGELOG][link-changelog] for more information what has changed recently. ## Testing ``` bash $ composer test
The MIT License (MIT). Please see LICENSE for more information., (*18)
An application structure for Zapheus framework.
MIT
skeleton structure application zapheus