In this tutorial I will explain how to execute composer vendor binaries without typing vendor/bin every time.
Normally when Behat is required a symlink is created in vendor/bin. To execute it you need to type the relative path of the Behat executable (vendor/bin/behat).
What I want to do is type behat instead. To achive this all you need to do is to add vendor/bin into your PATH:
To avoid typing this every time you log in to the command line you need to add it to your .bash_profile. Here is the change on mine:
--- a/.bash_profile Sun Sep 7 00:37:30 2014 +++ b/.bash_profile Sun Sep 7 00:37:35 2014 @@ -7,6 +7,6 @@ # User specific environment and startup programs -PATH=$PATH:$HOME/.local/bin:$HOME/bin +PATH=$PATH:vendor/bin:$HOME/.local/bin:$HOME/bin export PATH
Now when you type behat your shell will find Behat executable in vendor/bin directory.
Note 1: You will be able to execute behat only when your current working directory (cwd) is project root.
Note 2: If you have another behat in a directory that has higher precedence (e.g /usr/bin) that will be executed instead.