在 Symfony 中注册另一个包

cha*_*asr 2 php symfony

我正在开发一个可重用的包,该包将在 Packagist 上发布。

我想让捆绑包的配置尽可能简单。
但是,bundle 使用了几个涉及注册的 3rd 方 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
        );

        // ...
    }

    // ...
}
Run Code Online (Sandbox Code Playgroud)

有没有办法通过仅注册我创建的捆绑包来注册一组捆绑包?

也许AppKernel可以通过AppKernel在应用程序的实际中注册我的包来加载一种。

如果不可能,我将不胜感激给我原因。

Paw*_*zuk 5

不 - 不可能从包中注册包,在这种情况下最好的方法是清晰的安装文档。

看看其他开源项目是如何处理的。例如 FOSCommentBundle:https : //github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/Resources/doc/1-setting_up_the_bundle.md