So I'm trying to create a custom console command in Laravel 5.1 which does some helpful function for my project. I can do this fine when putting the console command in a file located at the base commands folder but not when I just to add a subdirectory.
'App\Console\Commands\SomeCustomCommandThatWorks',
'App\Console\Commands\MySubNameSpace\CustomCommandThatFails',
So how do I add my command like MySubNameSpace\Command
?
Namespace doesn't appear to have any effect on this. The namespace of the command could be App\Console\MySubNameSpace\MyCommand
or App\Console\MyCommand
both fail if the file is located at 'App\Console\Commands\MySubNameSpace\MyCommand'
. The file also fails if located at 'App\Console\Commands\MyCommand'
with namespace App\Console\MySubNameSpace\MyCommand
.
Right now I get this error.
Class App\Console\Commands\DeletePhantomServers does not exist
I have tried running composer dumpautoload but to no success.
Any help would be appreciated.
According to autoloading standards, none of the combinations you have above will work. The namespace needs to be set according to the directory. So if you have the command in this folder
Console\Commands\MySubNameSpace\MyCommand
your namespace has to be
App\Console\Commands\MySubNameSpace\MyCommand
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