毎回調べているのでメモ
phpでciを回すのによく使うものに
があります。
php7ならphanもですね。
これを、composerのrun-script 経由で叩けるようにしておくと、
毎回オプションなどを指定しなくて済むので楽です。
書き方を毎回調べているのでメモ的に残します。
composer.json(抜粋)
"scripts": { "l": "php -l ./src", "test": "./vendor/bin/phpunit -c ./phpunit.xml", "cs": "./vendor/bin/phpcs --standard=./codesniffer/ruleset.xml ./src ./tests", "cbf": "./vendor/bin/phpcbf --standard=./codesniffer/ruleset.xml ./src ./tests", "md": "./vendor/bin/phpmd ./src,./tests text ./messdetector/ruleset.xml", "ci": [ "@l", "@cs", "@md", "@test" ] }
解説
各コマンドのキーになっているところが、 composerのサブコマンドになります。
サブコマンドは、@
つきでエイリアスとして使用できるので、2重定義しなくて済みます。
複数のコマンドを実行したい時は、配列で指定します。
実行方法
composer run-script ci
定義した ci を実行します。
または、単に
composer ci
としても動きます。
サブコマンドにオプションを渡したいときは、 --
で区切ります。
composer run-script test -- --group=Foo
上記は、 test に--group=Foo
を渡して実行してくれます。
./vendor/bin/phpunit -c ./phpunit.xml --group=Foo
と同義です。