Artisan Commands not Working, No output returned.

If you’ve run into this error where Artisan Commands not Working or no longer responds, or you’re unable to execute artisan commands here is a fix for it. When you run php artisan -V you expect the version of Laravel to display instead, nothing shows. You run php artisan tinker and as usual, you expect tinker to open but nothing happens. In this guide, I will teach you how to solve this issue. Artisan Command No output returned.

solution to laravel artisan command not working, laravel php artisan commands not working

Personally, I faced this issued after upgrading from Laravel 6 to 8, but you could be facing this issue as a result of some other actions. However, here is a fix for it, particularly if you’ve just migrated to Laravel 8. You should also try this fix even if the error did not generate as a result of upgrading to Laravel 8, afterall there is no harm in trying.

How to Reproduce problem:

There could be several reasons why this error might pop up, but in my experience, upgrading from an older version of Laravel to a new version like version 8 will produce this error. When this happens, non of the Artisan commands will execute. php artisan -V will return nothing, php artisan tinker will not launch tinker and many other artisan commands will not respond.

Leave a comment below if yours is different other than what is stated above and also provide a solution if you’ve been able to fix it using a different method other than the solution I have provided here.

See Also:

Tips to become a good developer

Email Sending – How to setup Mailgun for Laravel 8

Vuejs gotcha – Find the error

What is causing this problem?

The error is a result of upgrading Laravel and many other dependencies. The console cannot display what is causing the error because the Exception handler has changed from what it was in your previous Laravel version to what it is now in Laravel 8.

The solution to Artisan Commands not Working

Open the exception handler file located in app\Exceptions\Handler.php

<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that are not reported.
     *
     * @var array
     */
    protected $dontReport = [
        //
    ];

    /**
     * A list of the inputs that are never flashed for validation exceptions.
     *
     * @var array
     */
    protected $dontFlash = [
        'password',
        'password_confirmation',
    ];

    /**
     * Report or log an exception.
     *
     * @param  \Exception  $exception
     * @return void
     */
    public function report(Exception $exception)
    {
        parent::report($exception);
    }

    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $exception
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $exception)
    {
        return parent::render($request, $exception);
    }
}

Highlight and delete everything you see in this file and populate the file with these code below:

<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that are not reported.
     *
     * @var array
     */
    protected $dontReport = [
        //
    ];

    /**
     * A list of the inputs that are never flashed for validation exceptions.
     *
     * @var array
     */
    protected $dontFlash = [
        'current_password',
        'password',
        'password_confirmation',
    ];

    /**
     * Register the exception handling callbacks for the application.
     *
     * @return void
     */
    public function register()
    {
        $this->reportable(function (Throwable $e) {
            //
        });
    }
}

Get the above code from a fresh Laravel 8 installation. Now return back to your console and run php artisan -V. Whatever error was preventing artisan commands from executing will be displayed in the console. If there was no error, your artisan commands should now execute successfully.

Was this article helpful? please leave a comment below

Leave a Comment

%d bloggers like this: