Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Created December 20, 2022 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziadoz/fddfc5d1d210d84e6e8812b15a9ecfda to your computer and use it in GitHub Desktop.
Save ziadoz/fddfc5d1d210d84e6e8812b15a9ecfda to your computer and use it in GitHub Desktop.
Replace Laravel Artisan Command Output With Custom Implementation
<?php
namespace App\Providers;
use App\YourCustomOutputStyle;
use Illuminate\Console\OutputStyle;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Extending the OutputStyle class within the Laravel container allows you to alter Artisan's output.
* For example, you could wrap OutputStyle in a class that also logs the output for ephemeral environments such as Fortrabbit.
*/
public function register()
{
$this->app->extend(OutputStyle::class, function (OutputStyle $output, $app) {
return new YourCustomOutputStyle($output);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment