2017 © Pedro Peláez
 

library lib-console

image

kasundon/lib-console

  • Tuesday, May 26, 2015
  • by KasunDon
  • Repository
  • 2 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Lib-Console

Simple PHP CLI Framework, (*1)

Installation

There are two ways to use lib-console., (*2)

1. Using Composer

composer.json file, (*3)

{
    "require": {
        "kasundon/lib-console": "~0.0.6"
    }
}
php composer.phar install

2. Using PHAR Archive (console.phar)

Fist of all, Download latest console.phar., (*4)

curl -O https://github.com/KasunDon/lib-console/raw/master/build/console.phar

Get help for console.phar

php console.phar -help

Setup Default Command file path

place console.json file to your current working directory. Leave emtpty file_path in order to use current working directory., (*5)

{
    "file_path": "commands/"
}

Writing Commands

Simply implement Command Interface on to your custom command class., (*6)

If using console.phar - Dont forget to require_once follwoing statement before implements from Command Interface.

require_once 'phar://console.phar/Command.php';

Standard Custom Command

<?php

class Test implements Command {

    /**
     * Pre-execution command setup
     */
    public function setup() 
    {
        CommandUtility::log("pre command setup");
    }

    /**
     * Executes command routines
     */
    public function execute() 
    {
        CommandUtility::log("execute");
    }

    /**
     *  Returns command name/description
     * 
     * @return string
     */
    public function getCommand() 
    {
        return "Test Command";
    }
}

Run Commands

Place app.php into current working directory and execute on following format. first argument is your custom command name. when pass in arguments use following format --abc 1., (*7)

Please note: class name will be use as command name., (*8)

php app.php Test --abc 1

Or using console.phar

php console.phar Test --abc 1

Using cli arguments in inside command script

lib-console automatically injecting input cli arguments into arguments property. you can simple use them as follows,, (*9)

 $this->arguments

Feel free to contribute / feedback

if any questions please feel free to contact kasun@phpbox.info

The Versions

26/05 2015

dev-master

9999999-dev

  Sources   Download

26/05 2015

0.0.6

0.0.6.0

  Sources   Download

26/05 2015

0.0.5

0.0.5.0

  Sources   Download

24/05 2015

0.0.1

0.0.1.0

  Sources   Download