定制 kasundon/lib-console 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kasundon/lib-console

最新稳定版本:0.0.6

Composer 安装命令:

composer require kasundon/lib-console

包简介

README 文档

README

Simple PHP CLI Framework

#Installation There are two ways to use lib-console.

####1. Using Composer composer.json file

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

####2. Using PHAR Archive (console.phar) Fist of all, Download latest console.phar.

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.

{
    "file_path": "commands/"
}

Writing Commands

Simply implement Command Interface on to your custom command class.

####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.

Please note: class name will be use as command name.

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,

 $this->arguments

##Feel free to contribute / feedback ###if any questions please feel free to contact kasun@phpbox.info

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-05-24