Search code examples
symfonycomposer-phppackagist

Force an old dependency to be installed with Symfony


Updating to Symfony 2.3 is easy if all the dependencies support it. One of the dependency I am using from Packagist says its requirement is Symfony <2.3. Therefore, I cannot install that library.

The library is a little old, and I know there is one or two problems, however, I wish I could still install it with composer.

How can I force composer to install the library dev-master even though packagist says <2.3 ?


Solution

  • You could fork it on github, change the composer.json to your setup of the bundle:

    "symfony/symfony":   "2.3.*",
    

    and add the fork as repository in your projects composer.json:

    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "youralias/highlight-bundle",
                "version": "dev-master",
                "source": {
                    "url": "https://github.com/youralias/HighlightBundle",
                    "type": "git",
                    "reference": "origin/master"
                },
                "target-dir": "Highlight"
            }
        }
    

    This will then take your fork instead of the original when you require: nicodmf/highlight-bundle

    As for the PSR-0

    "autoload": {
        "psr-0": {
            "": "src/",
            "Highlight\\": "vendor/youralias/highlight-bundle"
        }
    },
    

    And require:

    "require": [
        ...,
        "youralias/highlight-bundle": "dev-master"
    ]
    

    As cheesemacfly said "if it works with Symfony 2.3"