1

Before Flex, we could extend Sensio's DistributionBundle Composer/ScriptHandler.php to hook into bin/console and run commands as part of composer's "post-update-cmd" .

Unfortunately Flex eliminates the ScriptHandler file. What's the best approach with Flex? I tried creating an Application instead of ScriptHandler and calling that from "post-update-cmd":

#!/usr/bin/env php

    <?php
    // application.php

    require __DIR__.'/vendor/autoload.php';

    use Symfony\Component\Console\Application;
    use Mybundle\MyUpdateCommand;

    $application = new Application();

    // ... register commands
    $application->add(new MyUpdateCommand());
    $application->run();

But this throws an error "event returned with error code 127". Thanks!

1
  • You can create your own Composer plugin for this purpose, please refer Composer documentation on this topic. You can also browse Composer plugins to see if there is something that would help you to satisfy your needs. Commented Jul 29, 2019 at 13:26

1 Answer 1

2

You can just add the command to auto-scripts section of composer.json:

"scripts": {
    "auto-scripts": {
        ...
        ...
        "name:of:my:command": "symfony-cmd"
    }
}

This will run the script on every composer install/update.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.