lokhman/silex-tools

Tools for Silex 2.0+ framework

2.1.4 2017-05-16 13:57 UTC

This package is auto-updated.

Last update: 2024-12-16 21:53:06 UTC


README

StyleCI

Tools for Silex 2.0+ micro-framework.

Installation

You can install silex-tools with Composer:

composer require lokhman/silex-tools

Components

Suggested Components

Application Container

Class that overrides base Silex\Application class and provides automatic registration of ConfigServiceProvider, error handling and Tools Trait.

use Lokhman\Silex\Application as BaseApplication;

class Application extends BaseApplication {

    public function __construct(array $values = []) {
        $values['config.dir'] = __DIR__.'/../app/config';

        parent::__construct($values);

        // ...
    }

}

Route Class

Class that overrides base Silex\Route class and adds support for SecurityTrait. You can enable it with:

$app['route_class'] = 'Lokhman\Silex\Route';

Twig Service Provider

Extended service provider for traditional TwigServiceProvider that enables support for namespaces in special twig.paths option.

use Lokhman\Silex\Provider\TwigServiceProvider;

$app->register(new TwigServiceProvider(), [
    'twig.paths' => [
        'PublicBundle' => '/path/to/src/PublicBundle/Resources/views',
    ],
]);

$app->render('@PublicBundle/default/index.html.twig');

Tools Trait

Trait to be included in overridden Silex Application class. Provides various useful methods to be used in the container. This trait is automatically included into Application Container.

use Silex\Application as BaseApplication;
use Lokhman\Silex\Application\ToolsTrait;

class Application extends BaseApplication {

    use ToolsTrait;

    public function __construct(array $values = []) {
        parent::__construct($values);
    }

}

License

Library is available under the MIT license. The included LICENSE file describes this in detail.