saxulum/saxulum-bundle-provider

此包已被放弃,不再维护。没有建议的替代包。

Saxulum Bundle Provider

1.1.1 2015-03-25 15:39 UTC

This package is not auto-updated.

Last update: 2020-09-22 19:11:00 UTC


README

与 plain silex-php 兼容

Build Status Total Downloads Latest Stable Version Scrutinizer Code Quality

特性

  • 注册命令、控制器、Doctrine ORM 实体、翻译、Twig 模板

要求

  • php >=5.3
  • Silex ~1.1

建议

安装

通过 Composersaxulum/saxulum-bundle-provider 的形式。

控制台

使用 Saxulum 控制台 的安装指南。

控制器

使用 Saxulum 路由控制器提供者 的安装指南。

Doctrine ORM

AnnotationRegistry

在添加 composer 的 autoload.php 后添加此行

\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

使用 Doctrine DBAL 服务提供者 的安装指南。使用不带映射设置的 Doctrine ORM 服务提供者 的安装指南。

示例

$app->register(new DoctrineOrmServiceProvider(), array(
    'orm.proxies_dir' => __DIR__ . '/../../../../../doctrine/proxies'
));

翻译

使用 Saxulum 翻译提供者 的安装指南。

Twig

使用 Twig 提供者 的安装指南。

创建一个扩展 Saxulum\BundleProvider\Provider\AbstractBundleProvider 的提供者并注册它。

示例提供者

<?php

namespace Saxulum\Tests\BundleProvider\Sample;

use Saxulum\BundleProvider\Provider\AbstractBundleProvider;
use Silex\Application;

class BundleProvider extends AbstractBundleProvider
{
    public function register(Application $app)
    {
        $this->addCommands($app);
        $this->addControllers($app);
        $this->addDoctrineOrmMappings($app);
        $this->addTranslatorRessources($app);
        $this->addTwigLoaderFilesystemPath($app);
    }

    public function boot(Application $app) {}
}
$app->register(new BundleProvider());

用法

控制台

将命令添加到相对于你的扩展 BundleProviderCommand 文件夹,并扩展 Saxulum\Console\Command\AbstractCommand

控制器

将控制器添加到相对于你的 BundleProviderController 文件夹。

Doctrine ORM

将实体添加到相对于您的 BundleProviderEntity 文件夹中。

翻译

将翻译添加到相对于您的 BundleProviderResources/translations 文件夹中。例如一个名为 messages.en.yml 的文件。

Twig

将模板添加到相对于您的 BundleProviderResources/views 文件夹中。例如一个名为 test.html.twig 的文件。您可以通过以下方式渲染它:

$app['twig']->render('@SaxulumTestsBundleProviderSample/test.html.twig')