2017 © Pedro Peláez
 

library skeleton

An application structure for Zapheus framework.

image

zapheus/skeleton

An application structure for Zapheus framework.

  • Tuesday, May 22, 2018
  • by rougin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Skeleton

![Latest Version on Packagist][ico-version] Software License Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

An application structure for Zapheus framework., (*2)

Installation

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)

Adding Zapheus providers

``` 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); }

Adding dependencies to 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

License

The MIT License (MIT). Please see LICENSE for more information., (*18)

The Versions

22/05 2018

dev-master

9999999-dev https://github.com/zapheus/skeleton

An application structure for Zapheus framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

skeleton structure application zapheus