Support the ongoing development of Laravel.io →
posted 3 years ago
Laravel
Last updated 1 year ago.
0

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 3 years ago.

lse123 liked this reply

1

Thanks

Worked

I knew the solution but -- I did not know what use/import

You know any IDE that provides hints for Laravel... imports?

0

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.

lse123 liked this reply

1

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.