<?php /** * Only execute "composer update", * if the "composer.json" file changed * within the last 10 commits. */ function fileChanged() { $cmd = 'git --no-pager diff --name-only HEAD~10 -- ./composer.json'; exec($cmd, $output); return ($output[0] === 'composer.json') ? true : false; } if(fileChanged()) { exec('composer update'); }
By the way, if your repository contains a `composer.lock` file: use `exec(‘composer install –no-dev’)`.