PHP code example of skulich / laravel-command-output-buffer
1. Go to this page and download the library: Download skulich/laravel-command-output-buffer library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
skulich / laravel-command-output-buffer example snippets
use Illuminate\Console\Command;
use SKulich\LaravelCommandOutputBuffer\Console\Concerns\OutputBuffer;
class ProcessDataCommand extends Command
{
use OutputBuffer;
protected $signature = 'app:process-data';
public function handle(): int
{
$this->obStart();
$this->line('Processing item 1...');
$this->line('Processing item 2...');
$this->v('Verbose detail');
if ($this->hasErrors()) {
$this->obFlush(); // show accumulated output — something went wrong
return self::FAILURE;
}
$this->obClean(); // discard output — all ok
return self::SUCCESS;
}
}
public function handle(): int
{
$this->obStart($defer);
$this->info('Step 1 done');
$this->info('Step 2 done');
return self::SUCCESS;
// buffer is automatically flushed here when $defer is destroyed
}