Use of undefined constant MCRYPT_BLOWFISH - assumed 'MCRYPT_BLOWFISH'

Baranto picture Baranto · Mar 22, 2016 · Viewed 12.7k times · Source

I'm using Magento 2. Installed a theme and I want to upgrade my system. (And I'm using AMPPS on Mac)

php bin/magento setup:upgrade

When I command these line in Terminal, get this error:

[ErrorException] Use of undefined constant MCRYPT_BLOWFISH - assumed 'MCRYPT_BLOWFISH'

How can I debug and solve it? Thanks.

Answer

Alan Storm picture Alan Storm · Mar 22, 2016

MCRYPT_BLOWFISH is a PHP constant. This constant is defined by the mycrypt extension. If your version of PHP has mcrypt installed, this constant is present. The error message you're seeing

Use of undefined constant MCRYPT_BLOWFISH - assumed 'MCRYPT_BLOWFISH'

is telling you that this constant is not present. That means mycrypt is not installed or enabled for the version of PHP you're running. You need to install or enable mcrypt.

Some gotchas.

  • The version of PHP you're running on the command line may be different from the version of PHP you're using for Apache/nginx. $ which php, $ php -v, and php --info can tell you what's available for your CLI PHP

  • You may have the extension installed, but disabled via a php.ini file. You can find which php.ini files you're using in the --info call above, by running a small program that calls phpinfo(), or with $ php --ini