Install Composer and make a terminal shortcut on Mac OS X
Anybody using Laravel will be aware of composer which is used to install it via the terminal. 'Composer' itself is a cross-platform dependency manager just like Homebrew but mainly related to PHP libraries.
This article will explain how to install it on Mac OS X and more importantly add a terminal shortcut so you only need to install it the once.
So in the terminal lets start by installing composer by inputting the following.
curl -sS http://getcomposer.org/installer | php
Now normally if we wanted to run this we would simply use 'php composer.phar', but this only relates to the folder it was saved in. So based on this you would need to install it everytime you created a new website with Laravel. So now we want to create a universal shortcut.
First thing we need to do is move the 'composer.phar' to the universal directory '/usr/local/bin/'. For me I always create a folder to place it in, so for this I will create a 'composer' folder inside.
sudo mkdir /usr/local/bin/composer/
Now move the 'composer.phar' file into this newly created directory.
sudo mv composer.phar /usr/local/bin/composer/
Set up 'composer' as the shortcut
First open the '~/' directory.
Then create the '.bash_profile' file - the following input detects whether it already exists and only if it doesn't then creates it.
In order to edit this file you could use the terminal but I prefer to do it in the texteditor. So input the following to open the file.
open -e .bash_profile
In the texteditor add the following then save it.
alias composer="php /usr/local/bin/composer/composer.phar"
Now relaunch your terminal and you will be able to run Composer simply by inputting 'composer'. So try it...
It should by default show you the usage details for composer.
/ ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 1.6.4 2018-04-13 12:04:24 Usage: command [options] [arguments]
Hope this has helped.
Visitors also viewed these posts