2

I need to install an symfony2 bundle over the composer and do some stuff after the install process. So for the "stuff" after the install i add one line to the "post-install-cmd" in the composer.json

ServiceBundle\\Core\\Platform::registerService

and it calls the function, everything fine

    public static function registerService(Event $event) {
       //some stuff
       exit;
    }

The command I use:

php composer.phar update serviceplatform/bundles/poll

Now my question: Is it possible to get the name "serviceplatform/bundles/poll" or pass any arguments to the statement? I need the path from the bundle after the install.

Touki
  • 7,465
  • 3
  • 41
  • 63
Zero
  • 554
  • 9
  • 22

1 Answers1

2

extra node is what you're looking for - https://getcomposer.org/doc/04-schema.md#extra

In your composer.json:

"extra": {
    "your-parameter": "serviceplatform/bundles/poll"
}

Then, in your ServiceBundle\Core\Platform::registerService:

public static function registerService(Event $event) 
{
    $extras = $event->getComposer()->getPackage()->getExtra();
    $yourParameter = $extras['your-parameter'];
    //do your stuff
}

It should do the trick.

Vitalii Zurian
  • 17,858
  • 4
  • 64
  • 81
  • Okay. That should work..but i need a dynamic parameter. Means php composer.phar update serviceplatform/bundles/poll has parameter poll and php composer.phar update serviceplatform/bundles/test has parameter test. Is there a diffrent way or is the only way to change the parameter before every php composer.phar update – Zero Mar 24 '14 at 14:29