juu*_*uga 20 php symfony composer-php
我composer.json
包含以下声明:
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
Run Code Online (Sandbox Code Playgroud)
我想运行我所拥有的自定义控制台命令src/MyBundle/Command/MyCommand.php
.如何将其添加到脚本中以在composer中运行?
Mat*_*teo 23
您可以看到postinstall挂钩如何为Sensio DistributionBundle工作.
例如,这是您可以调用Hello World
Acme Demo包的命令:
ScriptHandler
<?php
namespace Acme\DemoBundle\Composer;
use Composer\Script\CommandEvent;
class ScriptHandler extends \Sensio\Bundle\DistributionBundle\Composer\ScriptHandler {
/**
* Call the demo command of the Acme Demo Bundle.
*
* @param $event CommandEvent A instance
*/
public static function helloWorld(CommandEvent $event)
{
$options = self::getOptions($event);
$consoleDir = self::getConsoleDir($event, 'hello world');
if (null === $consoleDir) {
return;
}
// $extraParam = '';
// if (!$options['who']) {
// $extraParam = ' --who';
// }
static::executeCommand($event, $consoleDir, 'acme:hello', $options['process-timeout']);
}
}
Run Code Online (Sandbox Code Playgroud)
您可以在json文件中管理额外的参数.
composer.json
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Acme\\DemoBundle\\Composer\\ScriptHandler::helloWorld"
],
Run Code Online (Sandbox Code Playgroud)
经测试
我扩展了ScriptHandler
sensio-distribution软件包的类:
sensio/distribution-bundle (v3.0.18)
Run Code Online (Sandbox Code Playgroud)
希望这个帮助
归档时间: |
|
查看次数: |
5543 次 |
最近记录: |