Add new events for plugins #3116

francoispluchino opened this Issue Jul 10, 2014 · 7 comments

4 participants


With the issue #3082, the plugins can achieve much more thing that now, but, they still cannot add new features in the Installer.

It would be interesting to add events to the Installer, allowing plugins to handle the Pool, before and after the analysis by the Solver.

For example, the plugin composer-asset-plugin, allows you to manage dependencies of assets (NPM et Bower), but for the dependencies using the URL in versions ({url}#{version}), it is necessary to create and add the VCS repository to the Pool, and not only to the RepositoryManager.

I propose to add these 2 events:

  • Composer\Installer\InstallerEvents::PRE_SOLVE_DEPENDENCIES
  • Composer\Installer\InstallerEvents::POST_SOLVE_DEPENDENCIES

I wonder why you need to support this dependency schema.

To me it makes sense to not support all possible ways to specify repositories/versions that bower/npm supports, especially if composer has an equivalent.


@nsams Because the dependencies of NPM/Bower package are analyzed, and that this type of schema is present. At the same time, it can be used for all anything else, and allows greater freedom for plugins. My plugin is just one example.

Composer member

I'm kind of starting to wonder if this is even a good idea. Maybe we should keep plugins limited as they are and you should just be using the right tool for the job. If you want to install npm deps, use npm?


@naderman: Yes, but in practice many packages consist of php plus javascript code, with dependencies to other javascript code. You can't handle that with npm/bower.

See also:


As I explain in the doc, the plugin is not intended to circumvent dependency managers, that are NPM or Bower, but to provide a simple solution to install the assets by a PHP project with Composer, in an environment that does not have nodejs.

Currently, for manage dependencies of javascript asset in a PHP project, we have several possibilities:

  1. Install Node.js and use NPM or Bower command line in addition to Composer command line
  2. Do the solution 1, but add the Composer scripts to automate the process
  3. Include assets directly in the project (really not recommended)
  4. Create a repository with all assets and include the composer.json file (and use Packagist or an VCS Repository)
  5. Adds Package Repository in composer.json with the direct download link
  6. Creates a Satis or Packagist server
  7. Other?

And in the best practices of Symfony2, it's recommended not to include the assets in the bundles.


Only the Composer\Installer\InstallerEvents::PRE_SOLVE_DEPENDENCIES event is required for my use case.

But it would be really interesting that the plugins can do more things, as Composer can now do a lot more things. For example, the Script system (#218, #257) and the Plugin system (#2013) seemed outside the scope of Composer, but were finally integrated.

@naderman Given that you have developed the plugin system, you're the more likely to find that the plugins have a very limited action scope for the moment. Just adding 2/3 lines, this would make great things with this excellent tool.

Of course, in my case, it is not vital, but it would avoid manually add the configuration in the root composer.json.

@Seldaek Seldaek added the Feature label Jul 19, 2014
@Seldaek Seldaek added this to the Nice To Have milestone Jul 19, 2014
@Seldaek Seldaek closed this Sep 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment