定制 decouple/cli 二次开发

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

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

decouple/cli

Composer 安装命令:

composer require decouple/cli

包简介

Hack command line application container created for Decouple Framework.

README 文档

README

Hack command line application container created for Decouple Framework.

Usage

<?hh // partial

use Decouple\CLI\App;
use Decouple\CLI\Request\Request;
use Decouple\Decoupler\Decoupler;
use Decouple\Registry\Paths;
use Decouple\Log\Log;

// Define a vector of valid commands
$commands = Vector {
  "Decouple\Test\TestCommand",
  "Decouple\DBAL_CLI\Command\MigrateUpCommand",
  "Decouple\DBAL_CLI\Command\MigrateDownCommand",
  "Decouple\DBAL_CLI\Command\MigrateRefreshCommand",
  "Decouple\DBAL_CLI\Command\SeedCommand"
};

// Remove the name of the binary .hh
$args = new Vector($argv);
if($args->get(0) == 'decouple.hh') { $args->removeKey(0); }

// Create the CLI Request
$request = new Request($args);

// Create a Decoupler injector instance
$decoupler = new Decoupler(Map {});

// Register a $paths container containing at least a path to the "config" dir
$paths = new Paths(Map {
  "config" => "/path/to/configs"
});

// Create the CLI App with the given Request,
$app = new App($request, $decoupler, new Paths($paths), $commands);

/**
* Using the Decoupler you can now add a parameter with any of the types below
* to your Command constructors and it will be automatically injected
*/
$services = Map {
  "Decouple\Log\Log" => new Log((string)$paths->get('logs') . "/cli.log"),
  "Decouple\Registry\Paths" => new Paths($paths),
  "Decouple\CLI\Request\Request" => $request
};
$app->addServices($services);

$app->execute();

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Hack

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-09