Created
December 20, 2022 11:27
-
-
Save ziadoz/fddfc5d1d210d84e6e8812b15a9ecfda to your computer and use it in GitHub Desktop.
Replace Laravel Artisan Command Output With Custom Implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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