{"action":"opened","issue":{"url":"https://api.github.com/repos/composer/composer/issues/4596","labels_url":"https://api.github.com/repos/composer/composer/issues/4596/labels{/name}","comments_url":"https://api.github.com/repos/composer/composer/issues/4596/comments","events_url":"https://api.github.com/repos/composer/composer/issues/4596/events","html_url":"https://github.com/composer/composer/issues/4596","id":116060641,"number":4596,"title":"Install plugin before fire events for common packages","user":{"login":"Great-Antique","id":1128310,"avatar_url":"https://avatars.githubusercontent.com/u/1128310?v=3","gravatar_id":"","url":"https://api.github.com/users/Great-Antique","html_url":"https://github.com/Great-Antique","followers_url":"https://api.github.com/users/Great-Antique/followers","following_url":"https://api.github.com/users/Great-Antique/following{/other_user}","gists_url":"https://api.github.com/users/Great-Antique/gists{/gist_id}","starred_url":"https://api.github.com/users/Great-Antique/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Great-Antique/subscriptions","organizations_url":"https://api.github.com/users/Great-Antique/orgs","repos_url":"https://api.github.com/users/Great-Antique/repos","events_url":"https://api.github.com/users/Great-Antique/events{/privacy}","received_events_url":"https://api.github.com/users/Great-Antique/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-10T08:27:36Z","updated_at":"2015-11-10T08:27:36Z","closed_at":null,"body":"Hi,\r\n\r\nwe have a number of sites and now we try to use Satis as main package repository (and disable Packagist). To add new packages to Satis we created plugin that solves dependencies on install/update and add not existing packages to Satis config and then rebuild it.\r\n\r\nBut now we had a problem with adding this plugin to out sites' Composer config: \r\n\r\nIf we add composer.json that has out plugin and some package (that does not exist in Satis yet) - the plugin wouldn't install (because of dependencies is not solved)\r\n\r\nBut if we install plugin first (add it to new composer.json and don't add another packages) and then add packages - it works fine. It would be a solution if we had one or two projects.\r\n\r\nMy proposal: install plugins and only after that start installing packages if it possible. What do you think about it?\r\n\r\nTo reproduce:\r\n\r\n```\r\n.\r\n..\r\nplugin\r\nproject\r\n```\r\n\r\nplugin/composer.json\r\n```\r\n{\r\n    \"name\": \"my/test-plugin\",\r\n    \"type\": \"composer-plugin\",\r\n    \"require\": {\r\n        \"composer-plugin-api\": \"^1.0\"\r\n    },\r\n    \"autoload\": {\r\n        \"psr-4\": {\r\n            \"My\\\\\": \".\"\r\n        }\r\n    },\r\n    \"extra\": {\r\n        \"class\": \"My\\\\MyTestPlugin\"\r\n    }\r\n}\r\n```\r\n\r\nplugin/MyTestPlugin.php\r\n```\r\n<?php\r\n\r\nnamespace My;\r\n\r\nuse Composer\\Composer;\r\nuse Composer\\IO\\IOInterface;\r\nuse Composer\\Installer\\InstallerEvents;\r\nuse Composer\\Installer\\InstallerEvent;\r\nuse Composer\\EventDispatcher\\EventSubscriberInterface;\r\nuse Composer\\Plugin\\PluginInterface;\r\n\r\nclass MyTestPlugin implements PluginInterface, EventSubscriberInterface\r\n{\r\n\r\n    /** @var IOInterface */\r\n    protected $io;\r\n\r\n    public function activate(Composer $composer, IOInterface $io)\r\n    {\r\n        $io->write(\"Activate\");\r\n        \r\n        $this->io = $io;\r\n    }\r\n\r\n    public static function getSubscribedEvents()\r\n    {\r\n        return [\r\n            InstallerEvents::PRE_DEPENDENCIES_SOLVING => [\r\n                ['preDependenciesSolving', 0],\r\n            ],\r\n        ];\r\n    }\r\n    \r\n    public function preDependenciesSolving(InstallerEvent $event)\r\n    {\r\n        $this->io->write(\"Try to solve dependencies\");\r\n    }\r\n    \r\n}\r\n```\r\n\r\nproject/composer.json\r\n```\r\n{\r\n    \"repositories\": [\r\n        {\r\n            \"type\": \"vcs\",\r\n            \"url\": \"../plugin\"\r\n        },\r\n        {\r\n            \"packagist\": false\r\n        }\r\n    ],\r\n    \"require\": {\r\n        \"my/test-plugin\": \"dev-master\",\r\n        \"my/not-exists-package\": \"~2.7\"\r\n    }\r\n}\r\n```\r\n\r\n```\r\ngirnyk ~/composertest $ cd project/\r\ngirnyk ~/composertest/project $ composer install\r\nLoading composer repositories with package information                                                            Installing dependencies (including require-dev)       \r\nYour requirements could not be resolved to an installable set of packages.\r\n\r\n  Problem 1\r\n    - The requested package my/not-exists-package could not be found in any version, there may be a typo in the package name.\r\n\r\nPotential causes:\r\n - A typo in the package name\r\n - The package is not available in a stable-enough version according to your minimum-stability setting\r\n   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.\r\n\r\nRead <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.\r\n```\r\n\r\nNow remove ```\"my/not-exists-package\": \"~2.7\"``` from project/composer.json\r\n\r\n```\r\ngirnyk ~/composertest/project $ composer install\r\nLoading composer repositories with package information                                                            Installing dependencies (including require-dev)       \r\n  - Installing my/test-plugin (dev-master 528abbf)\r\n    Cloning 528abbff58883028dc017f2fff68eacde6ea128c\r\n\r\nActivate\r\nWriting lock file\r\nGenerating autoload files\r\n```\r\n\r\nNow add ```\"my/not-exists-package\": \"~2.7\"``` to project/composer.json\r\n\r\n```\r\ngirnyk ~/composertest/project $ composer update\r\nActivate\r\nLoading composer repositories with package information                                                            Updating dependencies (including require-dev)         \r\nTry to solve dependencies\r\nYour requirements could not be resolved to an installable set of packages.\r\n\r\n  Problem 1\r\n    - The requested package my/not-exists-package could not be found in any version, there may be a typo in the package name.\r\n\r\nPotential causes:\r\n - A typo in the package name\r\n - The package is not available in a stable-enough version according to your minimum-stability setting\r\n   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.\r\n\r\nRead <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.\r\n```\r\n"}}