2017 © Pedro Peláez
 

library simple-php-cli

Very simple PHP CLI for school projects.

image

marcus-campos/simple-php-cli

Very simple PHP CLI for school projects.

  • Sunday, April 1, 2018
  • by marcus-campos
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

How use?

To create a project, open your terminal and run the following command:, (*1)

composer create-project marcus-campos/simple-php-cli MyCliAppName

Build commands

To build commands just run php run make: command <command_name>., (*2)

Util

When you create your command, you will have access to the Util class. It will normally be available within your class scope, see how you use it:, (*3)

<?php

namespace App\Commands;


use Console\BaseCommand;
use Console\Contracts\ConsoleContract;

class ClassName extends BaseCommand implements ConsoleContract
{
    public function execute()
    {
        //Get the argument in the first position
        $argument = $this->util->args()['arguments'][0];
        //Prints a line in the console
        $this->util->output()->writeLn('Hello world!', 'green');
        //Prints a line in the console containing the value passed in the parameter
        $this->util->output()->writeLn('My param ' . $argument, 'green');
    }
}

The Util class contains methods to help when creating your command, follow the list of some of them (click to know more)., (*4)

How to register your command?

To register your command, simply access the Command class, located in the ... /console/Command.php file, add another item to the $commands array. Ex:, (*5)

    private $commands = [
           ...
            'new:command' => [
                'action' => MyCommand::class.'@execute',
                'params' => [
                               'param1',
                               'param2',
                               'param3',
                               ...
                           ],
                'description' => 'My command description',
            ],
           ...
        ];

Ex2:, (*6)

Command without parameters, (*7)

    private $commands = [
           ...
            'sympla' => [
                'action' => SymplaCommand::class.'@inspire',
                'description' => 'Descrição do meu outro comando',
            ],
           ...
        ];

Note: The parameters registered in this array are only descriptive by the help function., (*8)

How to execute a command?

To execute a command simply type:, (*9)

    php run <nome_do_comando>

Ex:, (*10)

    php run help

If the command has any parameters, execute it as follows:, (*11)

    php run <nome_do_comando> <parametro1> <parametro2>

Ex:, (*12)

    php run make:command TestCommand

Contact

Marcus Campos - campos.v.marcus@gmail.com, (*13)

The Versions

01/04 2018

dev-master

9999999-dev

Very simple PHP CLI for school projects.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Marcus Vinicius Campos

php cli simple

01/04 2018

v0.2.2

0.2.2.0

Very simple PHP CLI for school projects.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Marcus Vinicius Campos

php cli simple

01/04 2018

v0.2.1

0.2.1.0

Very simple PHP CLI for school projects.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Marcus Vinicius Campos

php cli simple

01/04 2018

v0.2.0

0.2.0.0

Very simple PHP CLI for school projects.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Marcus Vinicius Campos

php cli simple

22/03 2018

dev-fix-util

dev-fix-util

Very simple PHP CLI for school projects.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Marcus Vinicius Campos

php cli simple

22/03 2018

dev-arguments

dev-arguments

Very simple PHP CLI for school projects.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Marcus Vinicius Campos

php cli simple

14/03 2018

v0.1.1

0.1.1.0

Very simple PHP CLI for school projects.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Marcus Vinicius Campos

php cli simple

14/03 2018

v0.1.0

0.1.0.0

Very simple PHP CLI for school projects.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

by Marcus Vinicius Campos

php cli simple