lokhman/silex-tools

Silex 2.0+ 框架的工具

2.1.4 2017-05-16 13:57 UTC

This package is auto-updated.

Last update: 2024-09-16 21:20:04 UTC


README

StyleCI

Silex 2.0+ 微型框架提供的工具。

安装

您可以使用 Composer 安装 silex-tools

composer require lokhman/silex-tools

组件

建议组件

应用程序容器

一个覆盖基本 Silex\Application 类的类,并提供自动注册 ConfigServiceProvider、错误处理和 工具特质

use Lokhman\Silex\Application as BaseApplication;

class Application extends BaseApplication {

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

        parent::__construct($values);

        // ...
    }

}

路由类

一个覆盖基本 Silex\Route 类的类,并添加了对 SecurityTrait 的支持。您可以使用以下命令启用它:

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

Twig 服务提供者

扩展服务提供者,用于传统的 TwigServiceProvider,它支持特殊 twig.paths 选项中的命名空间。

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');

工具特质

一个特质,应包含在覆盖的 Silex Application 类中。提供各种有用的方法,可在容器中使用。此特质自动包含在 应用程序容器 中。

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

class Application extends BaseApplication {

    use ToolsTrait;

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

}

许可证

库可在 MIT 许可证下使用。包含的 LICENSE 文件详细说明了这一点。