Mcrypt PHP extension required on Mac OS X
Asked Answered
P

6

20

I keep getting this error

Mcrypt PHP extension required

at the bottom after I run a composer update :

enter image description here

Since I am using Mac, I have tried running :

brew search mcrypt brew install php56-mcrypt

I still get the same error message.

Prosperous answered 29/3, 2015 at 13:59 Comment(4)
Sure that the mcrypt extension is not already installed, but only not activated yet in the php configuration?Sextans
I'm not sure if the installation went through because I still get the error "Mcrypt PHP extension required." in the bottom after running composer update.Prosperous
Well, look into the place in your file system where the extensions are installed...Sextans
It is best not to use mcrypt, it has been abandonware for nearly a decade now. It has therefore been deprecated and will be removed from the core and into PECL in PHP 7.2. It does not support standard PKCS#7 (née PKCS#5) padding, only non-standard null padding that can't even be used with binary data. mcrypt has many outstanding bugs dating back to 2003. Instead consider using defuse or RNCryptor, they provide a complete solution, are being maintained and is correct.Breaux
P
35

Steps

I solved this by running the following commands

brew update
brew upgrade
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php54-mcrypt
php --version // To Test your php 
sudo composer update

Result

No more Mcrypt warning !!

Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
Generating optimized class loader
Prosperous answered 21/5, 2015 at 17:38 Comment(4)
brew install homebrew/php/php55-mcrypt will do tooProgestational
Yeah as @BingHan said it will do it, just pick the good php version and your are good!Jevons
Error: homebrew/dupes was deprecated. This tap is now empty as all its formulae were migrated. Please update your answer.Klingel
brew tap homebrew/dupes Error: homebrew/dupes was deprecated. This tap is now empty as all its formulae were migrated.Conative
W
14

After update brew:

brew update
brew upgrade
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php

If you have installed php5.6 (or higher), you can use the following command to find out what versions are available in brew:

$ brew search mcrypt
homebrew/php/php53-mcrypt     homebrew/php/php55-mcrypt         homebrew/php/php70-mcrypt     mcrypt
homebrew/php/php54-mcrypt     homebrew/php/php56-mcrypt     homebrew/php/php71-mcrypt

In my case, I am using php7.0:

$ brew install php70-mcrypt
Wakashan answered 15/12, 2016 at 23:0 Comment(1)
brew search mcrypt is important because it will most likely return what you need. In my case (I assume they have consolidated the versioning) I got "libtomcrypt", "mcrypt", "scrypt", "ccrypt", and "bycrypt" on my search results. I then just ran brew install mcrypt and all was resolved. So great answer @WakashanAldrich
D
7

On macOS High Sierra I did this steps:

1- Search the package:

brew search mcrypt

Result:

==> Searching local taps... homebrew/php/php71-mcrypt mcrypt homebrew/php/php53-mcrypt
homebrew/php/php54-mcrypt homebrew/php/php55-mcrypt homebrew/php/php56-mcrypt homebrew/php/php70-mcrypt libtomcrypt

2- Search my php version to know what can I need to install:

php --version

Result:

PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

3- Install the correct package, for me was 7.1.7 => homebrew/php/php71-mcrypt

brew install homebrew/php/php71-mcrypt

4- Find the find "mcrypt.so" extension file

find /usr/ -type f -name "mcrypt.so"

Result:

find: /usr//local/Cellar/php71-mcrypt/7.1.13_19/mcrypt.so

5- Search the php.ini

php -i | grep 'Configuration File'

Result (if exist):

Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini

6- Add the next line at the end on /etc/php.ini (see the last step your correct path) the extension mcrypt.so

 extension=/usr/local/Cellar/php71-mcrypt/7.1.13_19/mcrypt.so

Finish, you can now execute your command.

Dizzy answered 1/2, 2018 at 21:34 Comment(3)
I am using XAMPP, it is not working here. Any other way?Astyanax
Error: homebrew/php was deprecated. This tap is now empty as all its formulae were migrated.Cthrine
I like watching this step.Toting
C
5

You'll need to add the line

 extension=mcrypt.so

In your phi.ini file responsible for the CLI PHP version. To find where it is, run:

php -i | grep 'Configuration File'
Curculio answered 29/3, 2015 at 15:20 Comment(5)
I already have it in my php.ini I checked it. Any other suggestions ?Prosperous
When I run php -i | grep 'Configuration File' I see this : Configuration File (php.ini) Path => /etc Loaded Configuration File => (none)Prosperous
Try this: run find /usr/lib/php/extensions -type f -name "mcrypt.so" this should give you the path where the extension is located. Then, add the directive extension_dir=/usr/lib/php./....../mcrypt.so before the extension=mcrypt.so of your php.iniCurculio
When I run find /usr/lib/php/extensions -type f -name "mcrypt.so" I don't have anything as my outcomes.Prosperous
@ihue did you ever find a solution?Congenial
P
3

In use XAMPP on my Mac, so I had to install php and then compile mcrypt using pecl, after that I copied mcrypt.so to XAMPP.

The actual list of available releases is: http://pecl.php.net/package/mcrypt

The commands was:

echo Install php...
brew install php
/usr/local/opt/php/bin/php -v

echo Correction of "error Connection to `ssl://pecl.php.net:443' failed"...
wget http://curl.haxx.se/ca/cacert.pem
sudo cp cacert.pem /private/etc/ssl/cert.pem
sudo mv cacert.pem /Applications/XAMPP/xamppfiles/share/openssl/cert.pem
/usr/local/opt/php/bin/pecl list-all

echo Compile and Install mcrypt.so...
sudo /usr/local/opt/php/bin/pecl install mcrypt-1.0.1

The last message of build process of pecl was:

Build process completed successfully
Installing '/usr/local/Cellar/php/7.2.7/pecl/20170718/mcrypt.so'
install ok: channel://pecl.php.net/mcrypt-1.0.1
Extension mcrypt enabled in php.ini

Based on path of build process I copied the compiled mcrypt.so to XAMPP and enable the extension on php.ini:

sudo cp /usr/local/Cellar/php/7.2.7/pecl/20170718/mcrypt.so /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20170718/mcrypt.so 
echo 'extension=mcrypt.so' >> /Applications/XAMPP/xamppfiles/etc/php.ini

Check if it works:

/Applications/XAMPP/bin/php -i | grep "mcrypt"

The result have to be:

mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

Remember to restart Apache to see it working using browser.

Maybe it helps someone and I win one thumbs up. Thanks

Paquito answered 27/6, 2018 at 16:45 Comment(0)
L
0

if you using brew try this :

1.Unistall existing php then Install shivammathur/php

add shivammathur php

brew tap shivammathur/php

change php version with you needed (5.6 or 7.2 or 7.4 or 8.1 or next version)

brew install shivammathur/php/[email protected]

2.Install shivammathur/extensions it s will add extension to php then

brew tap shivammathur/extensions

brew install shivammathur/extensions/[email protected]

then you install mcrypt with same version as php version

brew install [email protected]

then restart httpd

brew services restart httpd

Ref :

https://github.com/shivammathur/homebrew-php

https://github.com/shivammathur/homebrew-extensions

Lyophobic answered 19/1, 2023 at 1:41 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.