2017 © Pedro Peláez
 

library partyline

A Laravel 5 package to output to the console from outside of command classes

image

wilderborn/partyline

A Laravel 5 package to output to the console from outside of command classes

  • Thursday, June 15, 2017
  • by wilderborn
  • Repository
  • 6 Watchers
  • 141 Stars
  • 11,622 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 9 Forks
  • 2 Open issues
  • 2 Versions
  • 32 % Grown

The README.md

Partyline

This package allows you to output to the console from outside of command class., (*1)

For example, you might have a feature that does the same thing from a command and through the web. Until now, you may have found yourself duplicating code just to be able to output to the console in various places., (*2)

With Partyline, you can use output commands within your logic. If it's being run inside the console, you'll see it. Otherwise, nothing will happen., (*3)

Usage

In your console command's handle method, bind the command into Partyline using the facade:, (*4)

``` php public function handle() { \Partyline::bind($this); }, (*5)


Then in your regular classes, you may call any public `Illuminate\Console\Command` methods on the `Partyline` facade, just like you would inside the command class. ``` php \Partyline::info('foo'); // Equivalent to $this->info('foo') within your command.

Facade usage

You can either use the globally aliased facade with a slash:, (*6)

\Partyline::method();

Or, you can import the facade:, (*7)

use Wilderborn\Partyline\Facade as Partyline;

Partyline::method();

Installation

This package can be installed through Composer., (*8)

composer require wilderborn/partyline

For Laravel 5.4 and below, register the service provider and facade:, (*9)

``` php // config/app.php 'providers' => [ ... Wilderborn\Partyline\ServiceProvider::class, ... ],, (*10)

'aliases' => [ ... 'Partyline' => Wilderborn\Partyline\Facade::class, ... ], (*11)


For Laravel 5.5+, this package will be [automatically discovered](https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518). ## Tips If you have many commands classes, you may find it tedious to bind into Partyline every time. You may consider an abstract command class and bind inside the `run` method. ``` php class YourCommand extends AbstractCommand { public function handle() { // } }

``` php class AbstractCommand extends Command { /** * Run the console command. * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @return int */ public function run(InputInterface $input, OutputInterface $output) { \Partyline::bind($this);, (*12)

    return parent::run($input, $output);
}

} ```, (*13)

More info on our Statamic blog: https://statamic.com/blog/partyline, (*14)

The Versions

15/06 2017

dev-master

9999999-dev

A Laravel 5 package to output to the console from outside of command classes

  Sources   Download

MIT

01/06 2017

1.0

1.0.0.0

A Laravel 5 package to output to the console from outside of command classes

  Sources   Download

MIT