Here the composer file has a script that hooks into pre and post update/install commands. The logic is as follows:
- Composer fires the pre method, which touches a file
- Composer does its business
- When finished, it fires the post method which removes the touched file
If for some reason the file still exists, then something went wrong. Either composer is still running, or it ran and encountered a fatal error, e.g. missing package, no internet connection, version lock, etc. This can now be picked up by the PHP application by testing for the presence of the file.
The
composer.json
in this gist has a deliberate spelling error in the required package name to demonstrate a failed composer run