This website uses cookies to track usage of this website and to deliver targetted advertising. Please read our Cookie Policy and Privacy Policy for further details of our usage. Continued use of this website indicates acceptance of our use of these cookies.

Getting mcrypt extension working on PHP 7.3.6 and Homebrew on Macbook

Getting mcrypt extension working on PHP 7.3.6 and Homebrew on Macbook

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?

Step 1

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.

Step 2

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 :(

Step 3

Find the path to your in-use php.ini file by issuing the command php --ini.

Step 4

Open this folder in an editor such as visual studio code (code . in the directory mentioned in php --ini)

Step 5

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.

Step 6

Remove this line.

Step 7

Create an mcrypt.ini file in the conf.d directory. Write…

;mcrypt extension=”/usr/local/Cellar/php/7.3.6/pecl/20180731/mcrypt.so

…save the file.

Step 8

Restart the web server. If you are using Laravel Valet the command is…

valet restart

It should now be working and installed.


More Web Development, PHP, WordPress and Shopify Posts

Search Posts

Share on Social

Get in touch for a quick, free personalised web design quote

Need some help on your WordPress, Laravel or Shopify project?

Get A Web Quote