Laravel 5: "class App \ Commands \ Command not found"

In Laravel 5, I just ran php artisan make:command doMagicStuff

to create a generic command with a die () statement in the handler. However, when I try to send $ this-> (new DoMagicStuff ()), I get:

[Symfony\Component\Debug\Exception\FatalErrorException] Class 'App\Commands\Command' not found

If I remove it extends Command

, it works, although clearly not correct.

Is there any reason it can't find App \ Commands \ Command? (Note: there is no Command.php in. / App / Commands, so this is a hint, although it might work under the vendor directory. I did grep for "class command" but no luck.

+3


source to share


1 answer


Have you cloned the repo from github? There is a repository Command.php

in which there is nothing, just an empty thesis. My projects also have this, so ... weird.

Here: https://github.com/laravel/laravel/tree/5.0/app/Commands



Whenever you create a command, it is placed like namespace App\Commands;

, and you extends Command

, so it will appear in the directory App\Commands

for the class Command

, since it exists in the repo, it must exist in your copy too.

+2


source







All Articles