northern-lights / command
此包已被放弃,不再维护。未建议替代包。
Command是一个小型库,以面向对象的方式提供系统命令的执行
1.2.0
2018-05-01 22:27 UTC
Requires
- php: >=7.0
Requires (Dev)
- jakub-onderka/php-console-highlighter: ^0.3.2
- jakub-onderka/php-parallel-lint: ^1.0
- phpunit/php-invoker: ^1.1
- phpunit/phpunit: ^6.5
- squizlabs/php_codesniffer: ^3.2
This package is auto-updated.
Last update: 2022-03-25 15:13:46 UTC
README
Command是一个小型库,以面向对象的方式提供系统命令的执行
弃用
我决定弃用此项目。如果您想接管并继续维护它,欢迎联系我。
此存储库已归档,将不再进行更新。
原因是symfony/process是此项目所做的一切,以及它原本应该成为的一切,但要好得多,积极维护且完全成熟,因此实际上没有理由让此项目存在。
安装
通过Composer
$ composer require northern-lights/command
真的非常简单!
使用方法
<?php namespace NorthernLights\Command\Example; use NorthernLights\Command\Result\CommandResultInterface; use function NorthernLights\Command\Run as command; require __DIR__ . '/vendor/autoload.php'; /** @var CommandResultInterface $result */ $result = command('ls -all'); if ($result->isOk()) { // Note: $result->getOutput() will return an instance of OutputInterface which implements __toString() echo $result->getOutput() . PHP_EOL; } else { echo "Command failed with status code " . $result->getExitCode() . PHP_EOL; }
请参阅示例
请注意行"使用函数 NorthernLights\Command\Run as command",这至关重要,因为它将函数 NorthernLights\Command\Run 分配给命令别名。
如果您不想使用这种方式,请参阅Run函数声明
PSR-2 标准
库力求遵守PSR-2编码标准,因此我们包含了以下命令
$ composer check-style $ composer fix-style
注意:第二个命令实际上会修改文件
PSR-4 标准
库遵守PSR-4自动加载标准
测试
$ composer php-lint
$ composer test
许可证
MIT许可证(MIT)。请参阅许可证文件获取更多信息。