Cli-maker is library for automatically generating cli commands from any PHP class.
Switch branches/tags
Nothing to show
Clone or download
Maciej Wilgucki
Maciej Wilgucki readme
Latest commit 1df5982 Mar 13, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src v1.0 Mar 13, 2017
.gitignore v1.0 Mar 13, 2017
cli-maker v1.0 Mar 13, 2017
composer.json v1.0 Mar 13, 2017
license.md license Mar 13, 2017
readme.md readme Mar 13, 2017

readme.md

Cli-maker

Cli-maker is library for automatically generating cli commands from any PHP class.

This library requires PHP 7

Installation

composer require wilgucki/cli-maker

Usage

Create on root level of your application cli-maker.php file. Future version of this library will allow you to choose location of this file.

Add all class names you want to access from command line into this file. Currently library requires all class names to be unique (even if classes are using different namespaces). This will change in future version.

<?php
// cli-maker.php

return [
    \App\Namespace\Foo::class,
    \App\Another\Namespace\Bar::class,
];

To list all available commands run ./vendor/bin/cli-maker.

To run single command simply add it after cli-maker script.

./vendor/bin/cli-maker foo:bar

If converted method accepts parameters, you can add them in the same order as they were defined in your method. If you want to check those parameters you can use --help option.

./vendor/bin/cli-maker foo:bar --help

##TODO

  • pass array as argument
  • allow to customise config location
  • get method description from phpdoc
  • make method names unique
  • write tests
  • check if class is accessible