2017 © Pedro Peláez
 

library cakephp-subcommand-injector

CakePHP Subcommand Injector make it possible that automatical adding Task classes as subcommands of a Shell class.

image

suin/cakephp-subcommand-injector

CakePHP Subcommand Injector make it possible that automatical adding Task classes as subcommands of a Shell class.

  • Wednesday, May 2, 2018
  • by suin
  • Repository
  • 1 Watchers
  • 4 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

CakePHP Subcommand Injector

![travis-ci-badge] ![packagist-dt-badge] ![license-badge] ![release-version-badge] ![code-climate-maintainability-badge] ![code-climate-test-coverage-badge] !php-version-badge, (*1)

CakePHP Subcommand Injector make it possible that automatical adding Task classes as subcommands of a Shell class., (*2)

Features

  1. Automatically add subcommands to a shell.
  2. You don't have to write pipe code for each Tasks.

How it works

  1. Find shell task classes from a specific directory.
  2. Automatically add them to a shell as subcommands.

Installation

``` bash $ composer require suin/cakephp-subcommand-injector, (*3)


## Examples ```php class ExampleShell extends \Cake\Console\Shell { /** * @var SubcommandInjector */ private $subcommandInjector; public function __construct( \Cake\Console\ConsoleIo $io = null, \Cake\ORM\Locator\LocatorInterface $locator = null ) { parent::__construct($io, $locator); // 1. Initialize subcommand injector as a member of Shell class $this->subcommandInjector = SubcommandInjector::build( // Define how you find task classes: new TaskClassesConformingToPsr4( __DIR__ . '/my-app/src/', 'MyApp\\', __DIR__ . '/my-app/src/*/*Task.php' ), // Define mapping rules between task class and subcommand name: new NamingRuleByPatternMatching( 'MyApp\\{module_name}\\{task_name}Task', '{module_name}:{task_name}' ) ); } public function initialize() { // 2. Add tasks to this shell $this->subcommandInjector->addTasksTo($this); parent::initialize(); } public function getOptionParser() { $parser = parent::getOptionParser(); // 3. Add subcommands to this shell's parser return $this->subcommandInjector->addSubcommandsTo($this, $parser); } }

See more examples, visit ./example folder., (*4)

Changelog

Please see CHANGELOG for more details., (*5)

Contributing

Please see CONTRIBUTING for more details., (*6)

The Versions

02/05 2018

dev-master

9999999-dev

CakePHP Subcommand Injector make it possible that automatical adding Task classes as subcommands of a Shell class.

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp cakephp3

02/05 2018

1.0.2

1.0.2.0

CakePHP Subcommand Injector make it possible that automatical adding Task classes as subcommands of a Shell class.

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp cakephp3

01/05 2018

1.0.1

1.0.1.0

CakePHP Subcommand Injector make it possible that automatical adding Task classes as subcommands of a Shell class.

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp cakephp3

30/04 2018

1.0.0

1.0.0.0

CakePHP Subcommand Injector make it possible that automatical adding Task classes as subcommands of a Shell class.

  Sources   Download

MIT

The Requires

 

The Development Requires

cakephp cakephp3