I experiment with artisan CLI Laravel 6.x, I went call a command from another command or put in a route in Laravel call programmatically???
\Laravel\code\project1\routes\web.php artisanac but getting ERRORS - how to use the lib of the Artisan (import)
Symfony\Component\Debug\Exception\FatalThrowableError Class 'App\Console\Commands\Artisan' not found
http://homestead.test/test-artisan
routes/web.php Route::get('test-artisan', function () { $exitCode = Artisan::call('email:send', [ 'user' => 'test', '--sendEmail' => true, ]); });
Hi, you can make this work.
Currently it doesn't because it cannot resolve the Artisan class, which is a facade. The full class name is 'Illuminate\Support\Facades\Artisan', but it's alias is 'Artisan'. Add a '\' in front of Artisan to make it global. That will use the alias.
Route::get('test-artisan', function () {
$exitCode = \Artisan::call('email:send', [ 'user' => 'test', '--sendEmail' => true, ]);
});
All aliases are listed in the config\app.php file.
Another way to solve this is to add using statements on top of the file.
use Artisan;
// OR
use Illuminate\Support\Facades\Artisan;
Thanks
Worked
I knew the solution but -- I did not know what use/import
You know any IDE that provides hints for Laravel... imports?
I'm glad I could help. Please mark the thread as solved.
Regarding the IDE I cannot suggest any. I myself find hinting in PHP not good enough. It just frustrates and slows me down. When I gained enough insight into Laravel I switched it off completely. As a sideeffect I started to read the source code and gained a deep understanding of what is going on behind the scenes.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community