Install or Update Behat using composer

Profile picture for user devraj

For Behat you need at least PHP 5.3.3 version installed on your system. No matter you install Behat on Window, Mac or Ubuntu, steps will remain same.There are multiple ways to install Behat, The simplest way to install Behat is through Composer. Please install the composer on your OS if not installed already.

Advantage of installing Behat using composer is that you can easily update to latest version later. Below are the steps:

Step 1: Create composer.json in your project root directory.

Step 2: Add following json in composer.json.

{
    "require-dev": {
        "behat/behat": "~2.5"
    },
    "config": {
        "bin-dir": "bin/"
    }
}

Step 3: Replace 2.5 with the latest Behat version, which you can check here 

Step 4: Use below command to install libraries: 

$ composer install

For update Behat, add the latest version from link to the composer.json file and use below command.

$ composer update

Step 5: To check version of Behat use below command.

$ bin/behat --version
Tags