How are you using Artisan::call in your controller?
Did you import the Facade (use Artisan) or the class (use Illuminate\Support\Facades\Artisan)? The former should work, as should calling \Artisan::call(...).
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
Is there a way to run php artisan optimize --force from a Laravel 4.2 controller?
I tried to call Artisan::call('optimize', ['--force' => true]) but I get an this error Call to undefined method Illuminate\Support\Facades\Artisan::call().
Any thoughts on how to get around this would be appreciated. Thanks.
So I figured out the problem. My site was being accessed over a UNC path, which ended up being the problem. Moving the site to a local drive fixed the issue.
Please or to participate in this conversation.