crodas/cli
最新稳定版本:v0.2.1
Composer 安装命令:
composer require crodas/cli
包简介
Simple and silly abstraction on top of symfony/console
README 文档
README
Simple and silly abstraction on top of symfony/console
How does it work?
The main goal is to give a generic and extensible way of registering console applications.
The application itself should like like this (cli.php).
<?php require __DIR__ . '/vendor/autoload.php'; $cli = new crodas\cli\Cli("/tmp/some.cache.tmp"); // the vendors cli $cli->addDirectory(__DIR__ . '/vendor'); // add my APP directory $cli->addDirectory(__DIR__ . '/apps'); // run $cli->main();
Then inside apps/ we could have apps/cli/foobar.php and it should look like this:
<?php namespace myApp\Cli; /** * @Cli("foobar", "some text to describe my app") * @Arg('name', OPTIONAL, 'add name') * @Option('foobar', VALUE_REQUIRED|VALUE_IS_ARRAY, 'add name') */ function foobar_main($input, $output) { $arg = $input->getArgument('name'); $opt = $input->getOption('foobar'); $output->writeLn(json_encode(compact('arg', 'opt'))); }
Now we can easily do php cli.php foobar, foobar_main function would be called.
Benefits
- Console applications are discovered
- No autoloader needed
- No conventions to follow
- It can use some cache function to avoid scanning lots of directories and files everytime.
- Annotations :-)
- Plugins support
@Oneor@Crontabmake sure your command runs just once
统计信息
- 总下载量: 7.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 9
- 推荐数: 0
其他信息
- 授权协议: BSD-4-Clause
- 更新时间: 2013-11-16