smoren / mushroom-hook-manager
用于运行项目依赖项的 post-install/post-update 脚本的 Composer 插件
v1.0.0
2021-12-10 17:51 UTC
Requires
- php: >=7.2.0
- composer-plugin-api: ^2.1
Requires (Dev)
- composer/composer: ^2.0
This package is auto-updated.
Last update: 2024-09-11 01:16:09 UTC
README
用于运行项目依赖项的 post-install/post-update 脚本的 Composer 插件
在您的包中使用
可能的示例
在您的包源目录的根目录中创建名为 MushroomHooks.php
的文件,并包含以下内容
<?php
namespace Your\Package\Namespace;
class MushroomHooks
{
public static function afterInstall($params)
{
// some actions on after install your package...
}
public static function afterUpdate($params)
{
// some actions on after update your package...
}
}
接下来,将这些行添加到您的包的 composer.json
文件中
...
"require": {
"smoren/mushroom-hook-manager": "1.0.0",
...
},
...
"extra": {
...
"mushroom-use-hooks": true,
"mushroom-hooks": {
"after-install": [
"Your\\Package\\Namespace\\MushroomHooks::afterInstall"
],
"after-update": [
"Your\\Package\\Namespace\\MushroomHooks::afterUpdate"
]
}
}
...
您还可以在项目中向包的钩子传递一些参数(作为 afterInstall
和 afterUpdate
方法的参数)。
您的项目 composer.json
文件示例
...
"extra": {
...
"mushroom-hooks-params": {
"your-composer/package-name": {
"after-install": {
"some-param": 1,
"another-param": 2
},
"after-update": {
"foo": "bar"
}
}
}
}
...