dbemfica/phpcli
Composer 安装命令:
composer require dbemfica/phpcli
包简介
Aplication PHP CLI
README 文档
README
This is a lib simple to create commands in PHP using Command Line Interface
Create APP
Create a file index.php with this content
<?php require_once "vendor/autoload.php"; $command = new \PHPCLI\FirstCommand(); $app = new \PHPCLI\App($argv); $app->addCommand($command); $app->run();
After run this script php index.php
Create Command
<?php use PHPCLI\Command; class FirstCommand extends Command { public $name = "First"; public $description = "Command Example"; public $arguments = [ 'name' ]; public function execute() { echo "First command"; } }
Passing arguments to the command
os argumentos são pssando passados pelo bash com o prefixo --. Example php index.php --name Diogo
<?php use PHPCLI\Command; class FirstCommand extends Command { public $name = "First"; public $description = "Command Example"; public $arguments = [ 'name' ]; public function execute() { $name = $this->getArgument('name'); echo "Hello ".$name.PHP_EOL; } }
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-24