2017 © Pedro Peláez
 

library pimple-cli

CLI commands for Pimple applications

image

gitory/pimple-cli

CLI commands for Pimple applications

  • Wednesday, May 11, 2016
  • by MrJuliuss
  • Repository
  • 2 Watchers
  • 10 Stars
  • 10,382 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 6 % Grown

The README.md

PimpleCli

Build Status Latest Stable Version License Total Downloads Scrutinizer Code Quality, (*1)

PimpleCli on Packagist, (*2)

PimpleCli is a tool that makes it easy creating command line application., (*3)

PimpleCli works with a Pimple container (eg: a Silex application) and a Console Application (eg: using http://symfony.com/doc/current/components/console/introduction.html). PimpleCli's role is to discover commands in the Pimple container to make them availlable the the Console Application., (*4)

Commands needs to be registered as a service with a name ending in '.command'. The command can be anything (class, callable, etc.) that the console application understand. When using the Symfony\Component\Console\Application command should extends Symfony\Component\Console\Command\Command. You can take a look at the Console Components documentation to get started., (*5)

Installation

Through Composer :, (*6)

{
    "require": {
        "gitory/pimple-cli": "~1.0"
    }
}

Examples

Silex 2

composer.json, (*7)

{
    "require": {
        "silex/silex": "~2.0@dev",
        "gitory/pimple-cli": "~1.0",
        "symfony/console": "~2.0"
    }
}

GreetCommand.php, (*8)

namespace Acme\DemoBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class GreetCommand extends Command
{
    protected function configure()
    {
        $this
            ->setName('demo:greet')
            ->setDescription('Greet someone')
            ->addArgument('name', InputArgument::REQUIRED, 'Who do you want to greet?')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $name = $input->getArgument('name');
        $text = 'Hello '.$name;
        $output->writeln($text);
    }
}

index.php, (*9)

require_once __DIR__.'/vendor/autoload.php';
require_once 'GreetCommand.php';

$silexApp = new Silex\Application();
$silexApp->register(new Gitory\PimpleCli\ServiceCommandServiceProvider());

// add your command as services ending in '.command' in your DI
$silexApp['user.new.command'] = function () {
    return new Acme\DemoBundle\Command\GreetCommand();
};

$consoleApp = new Symfony\Component\Console\Application();
$consoleApp->addCommands($silexApp['command.resolver']->commands());
$consoleApp->run();

Launch in Cli : php index.php demo:greet John, (*10)

command command, (*11)

The Versions

11/05 2016

dev-master

9999999-dev

CLI commands for Pimple applications

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Richarte

02/09 2014

v1.0.0

1.0.0.0

CLI commands for Pimple applications

  Sources   Download

MIT

The Requires

 

The Development Requires

by Julien Richarte