我正在开发一个可重用的 bundle ,该 bundle 将在 Packagist 上发布。
我想让 bundle 的配置尽可能简单。
但是,该 bundle 使用了多个需要注册的第三方 bundle 。
实际上,这就是我需要做的:
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new FOS\UserBundle\FOSUserBundle(),
new Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle(),
new Gesdinet\JWTRefreshTokenBundle\GesdinetJWTRefreshTokenBundle(),
// ...
new RCH\JWTUserBundle\RCHJWTUserBundle(), // My bundle here
);
// ...
}
// ...
}
有没有一种方法可以通过仅注册我创建的 bundle 来注册一组 bundle ?
也许是一种AppKernel
,可以通过在应用程序的真实AppKernel
中注册我的包来加载。
如果不可能,我很乐意告诉我原因。
最佳答案
不 - 不可能从 bundle 中注册 bundle ,在这种情况下最好的方法是清除安装文档。
看看其他开源项目是如何处理它的。例如 FOSCommentBundle:https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/Resources/doc/1-setting_up_the_bundle.md
关于php - 在 Symfony 中注册来自另一个的包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35524147/