{"action":"created","issue":{"url":"https://api.github.com/repos/contao-community-alliance/composer-plugin/issues/41","labels_url":"https://api.github.com/repos/contao-community-alliance/composer-plugin/issues/41/labels{/name}","comments_url":"https://api.github.com/repos/contao-community-alliance/composer-plugin/issues/41/comments","events_url":"https://api.github.com/repos/contao-community-alliance/composer-plugin/issues/41/events","html_url":"https://github.com/contao-community-alliance/composer-plugin/pull/41","id":78706637,"number":41,"title":"[WIP] Supporting  Contao 3 and Contao 4","user":{"login":"aschempp","id":1073273,"avatar_url":"https://avatars.githubusercontent.com/u/1073273?v=3","gravatar_id":"","url":"https://api.github.com/users/aschempp","html_url":"https://github.com/aschempp","followers_url":"https://api.github.com/users/aschempp/followers","following_url":"https://api.github.com/users/aschempp/following{/other_user}","gists_url":"https://api.github.com/users/aschempp/gists{/gist_id}","starred_url":"https://api.github.com/users/aschempp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschempp/subscriptions","organizations_url":"https://api.github.com/users/aschempp/orgs","repos_url":"https://api.github.com/users/aschempp/repos","events_url":"https://api.github.com/users/aschempp/events{/privacy}","received_events_url":"https://api.github.com/users/aschempp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-20T21:33:19Z","updated_at":"2015-05-25T20:13:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/contao-community-alliance/composer-plugin/pulls/41","html_url":"https://github.com/contao-community-alliance/composer-plugin/pull/41","diff_url":"https://github.com/contao-community-alliance/composer-plugin/pull/41.diff","patch_url":"https://github.com/contao-community-alliance/composer-plugin/pull/41.patch"},"body":"This PR aims to fix https://github.com/contao/core-bundle/issues/278\r\n\r\nThe example extension can be found at https://github.com/aschempp/composer-test/blob/master/composer.json. The requirements are set on `contao/core-bundle` (or `contao/news-bundle` etc.) \r\n\r\nI had to make slight adjustments to the [composer-client](https://github.com/aschempp/composer-client/commits/develop) just to make it allow to install the develop-version of the plugin.\r\n\r\n## So far it works\r\n\r\n### In Contao 3\r\n 1. Add Composer manager through the backend (ER2). In my case it was a Contao 3.2.5\r\n 2. Go to command line to perform migration  \r\n 2. Add `repositories` for my fork of `composer-plugin`, [composer-client](https://github.com/aschempp/composer-client/commits/develop) and [composer-test](https://github.com/aschempp/composer-test) in your `composer.json`\r\n 3. Installing and uninstalling `aschempp/composer-test` works from both backend and command line\r\n\r\nPerforming migration in the backend caused a 30-sec timeout for me, because it tries to pull `contao/core-bundle` and all Symfony dependencies. That is however an existing problem of the Contao composer client, because it does install dependencies of `contao/core` (or `contao/core-bundle`) before the plugin is active and can stop it. We need to find a new workaround for that.\r\n\r\n### In Contao 4\r\n 1. Clean installation of Contao 4 using  \r\n     `composer create-project contao/standard-edition Contao4 4.*@dev`\r\n 2. Add `repositories` for my fork of `composer-plugin`, [composer-client](https://github.com/aschempp/composer-client/commits/develop) and [composer-test](https://github.com/aschempp/composer-test) in your `composer.json`\r\n 3. Installing and uninstalling `aschempp/composer-test` works on the command line\r\n 4. For the first time (the first extension requiring the plugin), you have to `composer update` several times. This is a known issue to the existing composer plugin.\r\n\r\n\r\n## ToDos\r\n - [ ] Rewrite the plugin and other classes to use the Environment instances directly\r\n - [ ] Fix existing unit tests that rely on removed methods\r\n - [ ] See how we can support unit tests (e.g. on Travis) for Contao 3\r\n - [ ] Make sure `contao/core` and all other \"provides\" are disallowed when requested by an extension\r\n\r\n--\r\n/cc @discordier @leofeyer @Toflar"},"comment":{"url":"https://api.github.com/repos/contao-community-alliance/composer-plugin/issues/comments/105305201","html_url":"https://github.com/contao-community-alliance/composer-plugin/pull/41#issuecomment-105305201","issue_url":"https://api.github.com/repos/contao-community-alliance/composer-plugin/issues/41","id":105305201,"user":{"login":"aschempp","id":1073273,"avatar_url":"https://avatars.githubusercontent.com/u/1073273?v=3","gravatar_id":"","url":"https://api.github.com/users/aschempp","html_url":"https://github.com/aschempp","followers_url":"https://api.github.com/users/aschempp/followers","following_url":"https://api.github.com/users/aschempp/following{/other_user}","gists_url":"https://api.github.com/users/aschempp/gists{/gist_id}","starred_url":"https://api.github.com/users/aschempp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschempp/subscriptions","organizations_url":"https://api.github.com/users/aschempp/orgs","repos_url":"https://api.github.com/users/aschempp/repos","events_url":"https://api.github.com/users/aschempp/events{/privacy}","received_events_url":"https://api.github.com/users/aschempp/received_events","type":"User","site_admin":false},"created_at":"2015-05-25T20:13:49Z","updated_at":"2015-05-25T20:13:49Z","body":"I did rewrite A LOT on the plugin today. I think I now have also completely understand how it works and what it's supposed to do to solve our problem (regarding installation). Explained in `composer.json` terms, it's fairly simply:\r\n\r\n 1. It will add a virtual package to composer, telling it that `contao/core` is already installed in the version of the available Contao installation.\r\n 2. This `contao/core` package now has a section that says\r\n\r\n        \"replace\": {\r\n            \"contao/core-bundle\": self.version,\r\n            \"contao/news-bundle\": self.version,\r\n            \"contao/calendar-bundle\": self.version\r\n            /* … all contao/contao 4 bundles */\r\n        }\r\n\r\n 3. It virtually adds a dependency to the installation to require the known version of the installation for `contao/core` and all bundles.\r\n\r\nProviding the packages will composer tell not to install anything if the given version is compatible with the requirements of a to-be-installed package. Having the requirement in the root will prevent composer from trying to update any of these packages, but fail to add the to-be-installed package.\r\n\r\nFor existing packages, adding `\"require\": { \"contao/core\": >3.2,<4 }` will work perfectly if Contao 3.4 is installed.\r\n\r\nFor packages supporting Contao 3 and 4, the requirement must be `\"require\": { \"contao/core-bundle\": >3.2,<5 }`. In Contao 3, the plugin will take care of \"providing\" `contao/core-bundle`. In Contao 4, it's actually available in composer (the plugin does not provide any package information on Contao 4)."}}