saxulum / saxulum-bundle-provider
Saxulum Bundle Provider
Requires
- php: >=5.3.3
- silex/silex: ~1.1
Requires (Dev)
- dflydev/doctrine-orm-service-provider: ~1.0,>=1.0.4
- phpunit/phpunit: 3.7.*
- saxulum/saxulum-console: ~2.0
- saxulum/saxulum-route-controller-provider: ~1.2,>=1.2.3
- saxulum/saxulum-translation-provider: ~1.0,>=1.0.3
- symfony/browser-kit: ~2.3
- twig/twig: >=1.8,<2.0-dev
This package is not auto-updated.
Last update: 2020-09-22 19:11:00 UTC
README
与 plain silex-php 兼容
特性
- 注册命令、控制器、Doctrine ORM 实体、翻译、Twig 模板
要求
- php >=5.3
- Silex ~1.1
建议
- Doctrine ORM 服务提供者 >= 1.0.4
- Saxulum 控制台 >= 1.2.0
- Saxulum 路由控制器提供者 >= 1.0.3
- Saxulum 翻译提供者 >= 1.0.0
安装
通过 Composer 以 saxulum/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());
用法
控制台
将命令添加到相对于你的扩展 BundleProvider
的 Command
文件夹,并扩展 Saxulum\Console\Command\AbstractCommand
。
控制器
将控制器添加到相对于你的 BundleProvider
的 Controller
文件夹。
Doctrine ORM
将实体添加到相对于您的 BundleProvider
的 Entity
文件夹中。
翻译
将翻译添加到相对于您的 BundleProvider
的 Resources/translations
文件夹中。例如一个名为 messages.en.yml
的文件。
Twig
将模板添加到相对于您的 BundleProvider
的 Resources/views
文件夹中。例如一个名为 test.html.twig
的文件。您可以通过以下方式渲染它:
$app['twig']->render('@SaxulumTestsBundleProviderSample/test.html.twig')