Search code examples
composer-phpbehatsymfony-dependency-injection

Resolving Dependency Conflicts Installing Behat and Laravel 5.3


Hello I am trying to install behat/behat via composer, however I am have dependency problems. I tried the below of many:

composer require behat/behat:"3.*" symfony/dependency-injection:"3.*" --dev

However, the output of above is

Your requirements could not be resolved to an installable set of packages.

Below is my composer.json file.

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.3.*",
        "dingo/api": "1.0.*@dev",
        "tymon/jwt-auth": "0.5.11",
        "phaza/laravel-postgis": "^3.0",
        "jenssegers/raven": "1.9.0",
        "guzzlehttp/guzzle": "~5.3|~6.0",
        "oureastudios/laravel5-braintree": "dev-master",
        "vinkla/algolia": "^2.1",
        "alexpechkarev/google-maps": "1.0.5",
        "pda/pheanstalk": "~3.0",
        "league/flysystem-aws-s3-v3": "~1.0",
        "pubnub/pubnub": "3.7.*",
        "maknz/slack": "^1.7",
        "intervention/image": "^2.3",
        "wilgucki/csv": "^0.5.1",
        "doctrine/dbal": "^2.5",
        "davibennun/laravel-push-notification": "@dev",
        "aloha/twilio": "^2.1",
        "laravel/socialite": "^2.0",
        "barryvdh/laravel-dompdf": "^0.8.0",
        "mockery/mockery": "1.0",
        "maxmind-db/reader": "~1.0",
        "predis/predis": "^1.1"
    },
    "require-dev": {
        "symfony/dom-crawler": "~3.1",
        "symfony/css-selector": "~3.1",
        "fzaninotto/faker": "~1.4",
        "phpunit/phpunit": "~5.0",
        "phpspec/phpspec": "~2.1",
        "johnkary/phpunit-speedtrap": "^1.0",
        "barryvdh/laravel-ide-helper": "^2.4"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php",
            "tests/Helpers/",
            "tests/Traits/"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled",
            "php artisan ide-helper:generate",
            "php artisan ide-helper:models -N",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
}

What combination of behat and symfony/dependency-injection I should install? I tried many versions ever issued the below command composer info behat/behat -a but still no avail.


Solution

  • Basically whenever you get into this dependency nightmare, you are highly recommended to make your required versions specific rather than with wildcards. In other words: give Composer less room for imagination.

    This is what I did to make it work:

    1. Guess which is the best fit

    Laravel 5.3 was released back in September 9, 2016, going over the Behat releases, the first major release before that was 3.1.0 which was released in march 28th, 2016. So that's the first version I put in Composer directly (ie. without any wildcards and such) like so:

    "behat/behat": "3.1.0",
    

    2. Run Stuff With No Strings Attached

    After that, I just ran the following:

    • composer dump-autoload: clean up caches
    • rm -rf vendor and rm composer.lock: just to make life easier
    • composer install --no-scripts: just to make sure that php artisan stuff don't run.
    • profit
    composer show | grep behat
    behat/behat                           v3.1.0               Scenario-oriented BDD framework for PHP 5.3
    behat/gherkin                         v4.5.1               Gherkin DSL parser for PHP 5.3
    behat/transliterator                  v1.2.0               String transliterator