By default the console command folder is in: MyProject\MyBundle\Command
and all works as expected, but if I move the folder in another directory like :MyProject\MyBundle\MyFolder\Command
on command execution it thrown an: [InvalidArgumentException] Command "command_name" is not defined.
I haven't been able to find anything useful after searching over the internet and reading all the documentation possibly related to this problem...
The question is: Exist a mode to move that folder or I'll be forced to use the default folder?
Thanks!
You can define it as a service:
my_command:
class: MyProject\MyBundle\MyFolder\Command\MyCommand
tags:
- { name: console.command }
You can read more about this method in Symfony
documentation.
Take a look at Symfony\Component\HttpKernel\Bundle\Bundle::registerCommands
As you can see, the Command directory is hard wired in. There is no option for changing it via configuration. If you really really really wanted to change the folder then override and clone this method in your MyBundle class. But it hardly seems worth the effort.
Using services (as @Andrey Sobkanyuk) suggested is probably a better long term solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With