2017 © Pedro Peláez
 

library console

image

clarity/console

  • Monday, August 15, 2016
  • by daison12006013
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Clarity Console

use this to build your own console command for your Phalcon applications., (*1)

Console

Let's create a simple console, (*2)

<?php

use Clarity\Console\Brood;

class SampleConsole extends Brood
{
    protected $alias = 'sample';
    protected $description = 'Just a sample class to test console';

    public function slash()
    {
        $this->comment('triggered!');
    }
}

Save the file as SampleConsole.php, (*3)


Bootstrap

Let's bootstrap the application on how we could probably create the executor., (*4)

#!/usr/bin/env php
<?php

$consoles = [
    SampleConsole::class,
];

use Symfony\Component\Console\Application;
$app = new Application(
    'Brood (c) Daison Cariño',
    'v0.0.1'
);

# let's check if the call came from CLI
if ( php_sapi_name() === 'cli' ) {

    # iterate the consoles array
    foreach ($consoles as $console) {
        $app->add(new $console);
    }
}

$app->run();

Save the above code as console or any you want, while slayer is brood., (*5)

Run it to your console:, (*6)

php console

The Versions