Skip to content

Instantly share code, notes, and snippets.

@tomjn
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save tomjn/772b12a1f393eca845c1 to your computer and use it in GitHub Desktop.

Select an option

Save tomjn/772b12a1f393eca845c1 to your computer and use it in GitHub Desktop.

Revisions

  1. tomjn revised this gist Aug 15, 2014. 2 changed files with 23 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions composer_checker.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    <?php
    // this file goes inside the src/cftp folder
    namespace cftp;

    use Composer\Script\Event;

    class composer_checker {
    public static function post(Event $event)
    {
    unlink('.composerrunning');
    }

    public static function pre( Event $event ) {
    touch('.composerrunning');
    }
    }
    7 changes: 7 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    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.
  2. tomjn created this gist Aug 15, 2014.
    16 changes: 16 additions & 0 deletions composer.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    {
    "require": {
    "justinrainsdasdfbow/json-schema": "~1.1"
    },
    "scripts": {
    "post-update-cmd": "cftp\\composer_checker::post",
    "post-install-cmd": "cftp\\composer_checker::post",
    "pre-install-cmd": "cftp\\composer_checker::pre",
    "pre-update-cmd": "cftp\\composer_checker::pre"
    },
    "autoload": {
    "psr-0": {
    "cftp": "src/"
    }
    }
    }