简体   繁体   中英

Symfony2 console command in a dependent bundle

I've developed a bundle, which is not a standalone Symfony2 application, but merely a layer between the framework and the final application, taking care of some common taks.

When I create a Bundle/Command/SomeCommand.php with an appropriate class within, the command isn't available in Symfony. When I, however, copy the same command to the "final" bundle, which extends upon classes from the "parent" bundle, the command is available there.

I suspect the bundle has to be registered somewhere in Kernel or such thing, but I'm struggling to find any information about that, so any idea would be greatly appreciated!

Thanks!

When Bundle is registered as a bundle, the command should be available when it's placed in Bundle/Command/SomeCommand.php (note the singular Command versus your plural form).

You can also tag it as a service since Symfony 2.4, you can register commands as services using the console.command tag.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM