composerで任意のコマンド・スクリプトを実行する方法

パッケージ管理のcomposerに任意のコマンド・スクリプトを実行出来るようにする方法のメモ

とりあえず下記覚えておけばいいと思う

イベント タイミング
pre-install-cmd composer install コマンドの実行前
post-install-cmd composer install コマンドの実行後
pre-update-cmd composer update コマンドの実行前
post-update-cmd composer update コマンドの実行後


スポンサーリンク





使い方

  "scripts": {
    "post-install-cmd": [
      "php hoge.php",
      "chmod -R 755 hogehoge"
    ]
  },

フックとして使えると思うけど、考えて使わないと余り使えないのかな。

デプロイ時の操作とはまた別で考えてコマンドを精査する。