lokhman / silex-tools
Tools for Silex 2.0+ framework
Requires
- lokhman/silex-config: ^2.0
- lokhman/silex-console: ^2.0
- lokhman/silex-firewall: ^2.0
- silex/silex: ~2.0
Suggests
- lokhman/silex-assetic: For using Assetic library
- lokhman/silex-autoreload: For using AutoReload functionality
- lokhman/silex-hashids: For using Hashids library
- lokhman/silex-restful: For implementing RESTful functionality
README
Tools for Silex 2.0+ micro-framework.
Installation
You can install silex-tools
with Composer:
composer require lokhman/silex-tools
Components
- Console Application
- Config Service Provider
- RESTful Service Provider
- Application Class
- Route Class
- Twig Service Provider
- Tools Trait
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.