For a considerable amount of time I have been using composer to organize the dependencies for my projects. Until recently I never really gave much thought to this as it was just something like many others, I did. I lived with the local vendor directories in each project never really thinking about how this affected me. A common practice is to have composer install developer dependencies like phpunit.
Something as trivial as this just makes my life that little bit easier
One thing was for sure I did not want to change that construct just be more efficient at working with it. The problem or dysfunction I experienced resulted form working on multiple projects simultaneously each having their own vendor tree. In variably I would find myself constantly typing things like vendor/bin/phpunit over and over again when all I really wanted to type is phpunit and have it just work. I found a rather simple solution which was to add the following to my .bash_login after all my other $PATH altering routines and restart my terminal session.
# Simply adding the local composer vendor bin directory to the path. export PATH=./vendor/bin/:${PATH}
Now with this little change I am able to just type phpunit and I am good to go. If I happen to have walked down into a sub-directory then of course the OS will cry about the file not being found but that’s minor. Furthermore this is obviously a mute point if you are working in an IDE like Eclipse or PHPStorm that completely abstracts this level of detail from you the developer. However as I often do find myself on the command line and something as trivial as this just makes my life that little bit easier and isn’t that what it’s all about?