So got an extension to build and need to install a web app that uses Mcrypt. Unfortunately, there seems to be an issue with Mcrypt on MacBooks with Homebrew and PHP 7.3.
So how to install php 7.3 on mac and get mcrypt up and running again?
They tell you to use PECL to install. But if, like me, you get an error… Warning: mkdir(): File exists in /usr/local/Cellar/php/7.2.5/share/php/pear/System.php on line 294 ERROR: failed to mkdir /usr/local/Cellar/php/7.2.5/pecl/20170718
It feels like you can’t get past this point. However following along with a similar issue (article https://javorszky.co.uk/2018/05/03/getting-xdebug-working-on-php-7-2-and-homebrew/) it appears that it can’t create a directory. Looking in /usr/local/Cellar/php/7.3.6 you see that pecl is a symlink. Remove this symlink.
Re-run the pecl install for mcrypt…. pecl install mcrypt-1.0.2. Success this time, the plugin is installed. Although don’t get over excited. There are more steps :(
Find the path to your in-use php.ini file by issuing the command php --ini.
Open this folder in an editor such as visual studio code (code . in the directory mentioned in php --ini)
At the very top of your php.ini file in this directory will be a declaration for the installed mcrypt extension. Its wrong. It’ll say something like extension=“mcrypt.so” and will cause errors in PHP at the moment.
Remove this line.
Create an mcrypt.ini file in the conf.d directory. Write…
…save the file.
Restart the web server. If you are using Laravel Valet the command is…
It should now be working and installed.