PHP Mcrypt on OSX with XAMPP
Was composer not able to find the mcrypt PHP extension? When I developing on my local machine I use XAMPP because it is easy to setup. I also tend to use Laravel for a lot of projects as well. If you are using the same, when doing a composer update
you have no doubt encountered this error. Mcrypt PHP extension required.
Writing lock file Generating autoload files Mcrypt PHP extension required. Script php artisan clear-compiled handling the post-install-cmd event returned with an error
It turns out there is an extremely easy way to fix this. Simply update your .bash_profile with the following text:
export PATH=/Applications/XAMPP/bin:$PATH
This will find the XAMPP version of PHP that has mcrypt installed first instead of the one that comes with OSX.
The .bash_profile file allows you to have user defined settings when using Terminal. If you want to user a different version of PHP, you can change it here. Do you want to setup shortcuts? A lot of people will create a shortcut so that ls -l
can be run by typing ll
.
To do that enter the following in your .bash_profile file.
alias ll="ls -l"
If for some reason you don’t have a .bash_profile, create it in your root user directory. If your username is jeff, the file will be /Users/jeff/.bash_profile
.
After you have made your change you may need to source your profile. Execute the following command inside terminal to do it.
source ~/.bash_profile
Once this is done, you should be able to do a composer update
without any errors occurring.
Image courtesy of Baitong333 / FreeDigitalPhotos.net