LaravelPackages.net
Acme Inc.
Toggle sidebar
gidato/laravel-console-output

Extensions to catch the output from console commands

5
0
v0.1.0
About gidato/laravel-console-output

gidato/laravel-console-output is a Laravel package for extensions to catch the output from console commands. It currently has 0 GitHub stars and 5 downloads on Packagist (latest version v0.1.0). Install it with composer require gidato/laravel-console-output. Discover more Laravel packages by gidato or browse all Laravel packages to compare alternatives.

Last updated

Gidato / Laravel-Console-Output

This provides an extensions to the console commands, to allow other commands to be called, but the output to be collected rather than printed to the screen.

As the normal output converts the output to a string, this allows objects to returned provided they have the __toString() method

Installation


composer require gidato/laravel-console-output

Example Use

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Gidato\Console\Commands\Concerns\CallsCommandsAndCollectsOutput;

class MyCommand extends Command
{
    \\ include the trait
    use CallsCommandsAndCollectsOutput;

    .
    .
    .

    public function handle()
    {
        $this->callAndCollect($response, 'another:command');
        $lines = $response->getLines();

        $this->callSilentAndCollect($response, 'another:command');
        $lines = $response->getLines();

    }
}

In each of these call commands, the response from the underlying command is returned, and can be checked.

The output can then be retrieved from the response by using the getLines() method.

License

This software is open-sourced software licensed under the MIT license.

Star History Chart