[英]PHP Composer scripts don't fire
I'm trying to get post install and post update scripts working in a Composer package. 我正在尝试在Composer包中使用post安装和发布更新脚本。 Here's an excerpt from the
composer.json
file: 以下是
composer.json
文件的摘录:
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"scripts": {
"post-update-cmd": [
"App\\Install\\ComposerScripts::postUpdate"
],
"post-install-cmd": [
"App\\Install\\ComposerScripts::postInstall",
"./test.sh"
]
}
And here is ComposerScripts.php
: 这是
ComposerScripts.php
:
<?php
namespace App\Install;
use Composer\Script\Event;
class ComposerScripts
{
public static function postInstall(Event $event)
{
$io = $event->getIO();
if ($io->askConfirmation('Install Mecab? ', false)) {
return true;
}
exit;
}
public static function postUpdate(Event $event)
{
$event->getIO()->write("Working!");
return true;
}
}
And the file test.sh
: 和文件
test.sh
:
#!/bin/sh
echo Working
The ComposerScripts methods work if I test them with composer run-script
and the test.sh
script works fine, but when I install or update the package, nothing happens at all. 如果我使用
composer run-script
测试它们并且test.sh
脚本工作正常,则ComposerScripts方法有效,但是当我安装或更新包时,根本没有任何事情发生。 No output, no error, nothing. 没有输出,没有错误,没有。 Any idea what's going on here?
知道这里发生了什么吗?
try with 尝试
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"scripts": {
"post-update-cmd": [
"App\\Install\\ComposerScripts::postUpdate"
],
"post-install-cmd": [
"App\\Install\\ComposerScripts::postInstall",
"bash test.sh"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.