contao-community-alliance / composer-plugin

Composer plugin that provide contao integration and installer.
GNU Lesser General Public License v3.0
7 stars 10 forks source link

[WIP] Supporting Contao 3 and Contao 4 #41

Closed aschempp closed 9 years ago

aschempp commented 9 years ago

This PR aims to fix https://github.com/contao/core-bundle/issues/278

The 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.)

I had to make slight adjustments to the composer-client just to make it allow to install the develop-version of the plugin.

So far it works

In Contao 3

  1. Add Composer manager through the backend (ER2). In my case it was a Contao 3.2.5
  2. Go to command line to perform migration
  3. Add repositories for my fork of composer-plugin, composer-client and composer-test in your composer.json
  4. Installing and uninstalling aschempp/composer-test works from both backend and command line

Performing 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.

In Contao 4

  1. Clean installation of Contao 4 using
    composer create-project contao/standard-edition Contao4 4.*@dev
  2. Add repositories for my fork of composer-plugin, composer-client and composer-test in your composer.json
  3. Installing and uninstalling aschempp/composer-test works on the command line
  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.

    ToDos

    • [ ] Rewrite the plugin and other classes to use the Environment instances directly
    • [ ] Fix existing unit tests that rely on removed methods
    • [ ] See how we can support unit tests (e.g. on Travis) for Contao 3
    • [ ] Make sure contao/core and all other "provides" are disallowed when requested by an extension

/cc @discordier @leofeyer @Toflar

aschempp commented 9 years ago

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:

  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.
  2. This contao/core package now has a section that says

    "replace": {
       "contao/core-bundle": self.version,
       "contao/news-bundle": self.version,
       "contao/calendar-bundle": self.version
       /* … all contao/contao 4 bundles */
    }
  3. It virtually adds a dependency to the installation to require the known version of the installation for contao/core and all bundles.

Providing 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.

For existing packages, adding "require": { "contao/core": >3.2,<4 } will work perfectly if Contao 3.4 is installed.

For 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).

aschempp commented 9 years ago

How do we want to continue here? If there is no feedback from anyone, we can't continue with the development.

I'm not familiar with the CCA organisation, is the organisation supposed to support this repo? Otherwise if there is noone available to maintain it, maybe it should be transferred?

/cc @xtra @tristanlins

tristanlins commented 9 years ago

I'm out of scope :-/

/fw @xtra

discordier commented 9 years ago

@aschempp Sorry I had no time to make indepth checks and tests on your approach. As we discussed on mumble while you were initially writing this, I am still not convinced that all the corner cases we solved in the past will still be covered.

The overall picture I see here, as described in your comment before, is pretty good and nifty. Yet it must be polished.

Now a little offtopic On the generic question about maintaining this, yes the CCA is maintaining it. But as you might have already noticed, we are a bunch of Contao enthusiasts dedicating our spare time to projects for the public. We maintain projects because "there is a need for them" or because they need an incubation home. The bad part of the story is, that aside from @stefanheimes and myself, we have pretty few people in the CCA that are able to code but way too many (important) projects that would need more manpower. Therefore it simply takes time to check all PRs and issues, I bet you know that. :)

aschempp commented 9 years ago

So how should we continue here? My PR is supposed to show that my attempt works. Would it make sense to get the composer plugin developed by the Contao core team? Because it is pretty essential for all extension developers and therefore the success of Contao imho.

discordier commented 9 years ago

I have rebased your PR and fixed the unit test as good as I could. See contao4 branch.

The contao4 environment however is not tested at all yet.