Framework: Artisan::output() returns empty string

Created on 8 Nov 2018  路  8Comments  路  Source: laravel/framework

  • Laravel Version: 5.7.13
  • PHP Version: 7.1.23

Description:

Artisan::output() only returns an empty string.

Steps To Reproduce:

  • open Tinker
  • execute Artisan::call('inspire'); Artisan::output();

Most helpful comment

Just in case someone will google for words Artisan::output() is empty during tests in Laravel 5.7 or Laravel 5.8:

Here is the solution, use
public $mockConsoleOutput = false; in your TestCase class.
this is something introduced in Laravel 5.7, but never documented

All 8 comments

@michapietsch I have this issue as well. Did you make an upgrade from previous version to 5.7 too? Fresh installation of Laravel 5.7 works just fine on Artisan::output()

Update on the issue , something to do with laravel/telescope

If you have it installed, you can disable the watcher in config/telescope.php

Should be some other solution like priority/etc instead of disabling it completely in Telescope.

@sarfraznawaz2005 I think in this case we need to choose either one of them, since both telescope and Artisan::output uses symfony's console BufferedOutput which empties the buffer. And so it makes it has first come first serve behaviour.

https://github.com/laravel/telescope/issues/151#issuecomment-432787712

Closing this as the explanation has been given in the linked issue.

Should be some other solution like priority/etc instead of disabling it completely in Telescope.

Yes, set telescope config:

    Watchers\CommandWatcher::class => [
        'enabled' => env('TELESCOPE_COMMAND_WATCHER', true),
        'ignore' => ['migrate', 'migrate:status'] //etc
    ],

Just in case someone will google for words Artisan::output() is empty during tests in Laravel 5.7 or Laravel 5.8:

Here is the solution, use
public $mockConsoleOutput = false; in your TestCase class.
this is something introduced in Laravel 5.7, but never documented

In your \Illuminate\Console\Command subclass, you should write your output using "$this->line()" or other similar methods, then you could get your output using "Artisan::output()".

Was this page helpful?
0 / 5 - 0 ratings