PHPackages                             skulich/laravel-command-output-buffer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. skulich/laravel-command-output-buffer

ActiveLibrary[CLI &amp; Console](/categories/cli)

skulich/laravel-command-output-buffer
=====================================

A trait for buffering Artisan Command Output in Laravel

v1.0.0(1mo ago)01MITPHPPHP ^8.3CI passing

Since Apr 17Pushed 1mo agoCompare

[ Source](https://github.com/skulich/laravel-command-output-buffer)[ Packagist](https://packagist.org/packages/skulich/laravel-command-output-buffer)[ RSS](/packages/skulich-laravel-command-output-buffer/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (9)Versions (2)Used By (0)

Laravel Command Output Buffer
=============================

[](#laravel-command-output-buffer)

[![Latest Version on Packagist](https://camo.githubusercontent.com/adb5ffe1e6b751ee3931022b0e50a9fdae1a1667e8107c00fce931ab5aba3e76/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736b756c6963682f6c61726176656c2d636f6d6d616e642d6f75747075742d6275666665722e737667)](https://packagist.org/packages/skulich/laravel-command-output-buffer)[![PHP Version Require](https://camo.githubusercontent.com/4aa14354ea9fc3b47922297f188e1e1c2eb56af2f4c2688209770eb4bfde6731/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736b756c6963682f6c61726176656c2d636f6d6d616e642d6f75747075742d627566666572)](https://camo.githubusercontent.com/4aa14354ea9fc3b47922297f188e1e1c2eb56af2f4c2688209770eb4bfde6731/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736b756c6963682f6c61726176656c2d636f6d6d616e642d6f75747075742d627566666572)[![Laravel Version](https://camo.githubusercontent.com/5b003f397b180da47f6e9f5c8e782d73a283bba08805966f085a106905edb58a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d25354531322e3025323025374325374325323025354531332e302d7265643f6c6f676f3d6c61726176656c)](https://camo.githubusercontent.com/5b003f397b180da47f6e9f5c8e782d73a283bba08805966f085a106905edb58a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d25354531322e3025323025374325374325323025354531332e302d7265643f6c6f676f3d6c61726176656c)[![Run Tests](https://github.com/skulich/laravel-command-output-buffer/actions/workflows/tests.yml/badge.svg)](https://github.com/skulich/laravel-command-output-buffer/actions)[![Code Coverage](https://camo.githubusercontent.com/32855e94577df9d0a30995653b17d33a5fbfdf644518f96ea0374313397d19b7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e)](https://camo.githubusercontent.com/32855e94577df9d0a30995653b17d33a5fbfdf644518f96ea0374313397d19b7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e)[![License](https://camo.githubusercontent.com/1c19192b776677849b4fb9d2292be3dafa49b98c62c423b0e0af16123e3fc0f6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736b756c6963682f6c61726176656c2d636f6d6d616e642d6f75747075742d6275666665722e737667)](https://camo.githubusercontent.com/1c19192b776677849b4fb9d2292be3dafa49b98c62c423b0e0af16123e3fc0f6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736b756c6963682f6c61726176656c2d636f6d6d616e642d6f75747075742d6275666665722e737667)[![Total Downloads](https://camo.githubusercontent.com/78c9fd1d002484c3cbc7aaa4b78913fdfb2ff311133f0d782518afacead21afc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736b756c6963682f6c61726176656c2d636f6d6d616e642d6f75747075742d6275666665722e737667)](https://camo.githubusercontent.com/78c9fd1d002484c3cbc7aaa4b78913fdfb2ff311133f0d782518afacead21afc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736b756c6963682f6c61726176656c2d636f6d6d616e642d6f75747075742d6275666665722e737667)

A trait for buffering Artisan Command Output in Laravel. Inspired by PHP's `ob_start()` / `ob_flush()`.

**Use cases:**

- **Conditional output** — accumulate output during command execution, then decide to show it (flush) or discard it (clean) based on the result
- **Deferred output** — collect output and display it all at once at the right moment

Installation
------------

[](#installation)

```
composer require skulich/laravel-command-output-buffer
```

Usage
-----

[](#usage)

Add the `OutputBuffer` trait to your Artisan command:

```
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;
    }
}
```

### Deferred output

[](#deferred-output)

Pass a variable to `obStart()` to auto-flush when it goes out of scope:

```
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
}
```

API
---

[](#api)

All `ob*` methods are `protected` — they are meant to be called from within the command itself.

MethodDescription`obStart()`Start buffering output`obStart(&$defer)`Start buffering with auto-flush on scope exit`obPause()`Pause buffering — output goes directly to console`obStop()`Stop buffering and clear the buffer`obClean()`Clear the buffer without stopping`obFlush()`Output all buffered lines to the console`v($string, $style)`Buffer a line only when `-v` (verbose)`vv($string, $style)`Buffer a line only when `-vv` (very verbose)`vvv($string, $style)`Buffer a line only when `-vvv` (debug)The `line()` method is automatically intercepted — when buffering is active, output goes to the buffer instead of the console.

Tests
-----

[](#tests)

Run the entire test suite:

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for more information.

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance89

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

53d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/170199581?v=4)[Siarhei Kulich](/maintainers/skulich)[@skulich](https://github.com/skulich)

---

Top Contributors

[![skulich](https://avatars.githubusercontent.com/u/170199581?v=4)](https://github.com/skulich "skulich (4 commits)")

---

Tags

laravelcommandBufferoutput

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/skulich-laravel-command-output-buffer/health.svg)

```
[![Health](https://phpackages.com/badges/skulich-laravel-command-output-buffer/health.svg)](https://phpackages.com/packages/skulich-laravel-command-output-buffer)
```

###  Alternatives

[ronasit/laravel-entity-generator

Provided console command for generating entities.

2152.5k](/packages/ronasit-laravel-entity-generator)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21313.7k3](/packages/ecotone-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
