Support the ongoing development of →
Last updated 2 weeks ago.

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;
Last updated 1 year ago.



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!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 - All rights reserved.