0

I have set up laravel/homestead, now when I use composer install on a project, I get the error message:

The requested PHP extension mcrypt is missing from your system

(I know I shouldn't use mcrypt anymore, but the project was handed over to me so I cant change this for now)

I m using PHP 7.1 (where mcrypt is marked deprecated I think but still usable if I activate it?)

php -v shows "7.1.30"

I added extension=php_mcrypt.dll into my php.ini and then restarted homestead (halt & up again) I can see the line in the php.ini now but php -m does not show mcrypt... and composer install still fails.

How can I activate mcrypt in homestead?

Martin Evans
  • 45,791
  • 17
  • 81
  • 97
alloisxp
  • 175
  • 3
  • 16
  • 1
    There may be more than 1 php.ini, one for CLI and one for web. Make sure you're updating the right one. Also, if you're using Homestead, then you're probably using a Vagrant box that's running Ubuntu, so DLL files would not be valid. – aynber Aug 22 '19 at 16:32
  • 1
    Possible duplicate of [php 7 Mcrypt PHP extension required](https://stackoverflow.com/questions/36402000/php-7-mcrypt-php-extension-required) – aynber Aug 22 '19 at 16:33
  • @DiogoSanto he said he added `extension=php_mcrypt.dll` to `php.ini` and you're talking about unix? @aynber MCrypt was removed from PHP7 for one of the main reasons why you want to upgrade PHP: Security. The MCrypt library is not maintained anymore. There is no way to fix it, it's simply not there anymore. You need to change the code or downgrade (not recommended!!!). – Flash Thunder Aug 22 '19 at 17:56
  • I'd recommend doing `composer require phpseclib/mcrypt_compat`. That'll install a pure-PHP mcrypt shim that'll eliminate the need for the mcrypt extension. – neubert Aug 23 '19 at 03:07
  • phpenmod encrypt gives me: WARNING: Module mcrypt ini file doesn't exist under /etc/php/7.3/mods-available WARNING: Module mcrypt ini file doesn't exist under /etc/php/7.3/mods-available WARNING: Module mcrypt ini file doesn't exist under /etc/php/7.3/mods-available WARNING: Module mcrypt ini file doesn't exist under /etc/php/7.2/mods-available ... (do I have to instal the extension somehow? Or is it already inside Homestead and only needs to be activated?) – alloisxp Aug 23 '19 at 07:45
  • @FlashThunder you are completely right! I removed it now. – Diogo Santo Aug 23 '19 at 07:58

1 Answers1

-1

MCrypt was removed from PHP7 for one of the main reasons why you want to upgrade PHP: Security. The MCrypt library is not maintained anymore. There is no way to fix it on Windows, it's simply not there anymore. You need to change the code or downgrade (not recommended!!!).

Flash Thunder
  • 11,672
  • 8
  • 47
  • 91
  • Would be cool, but as I wrote, right now I have no choice because its a legacy project that was just given to me, I need to set it up locally first then I can think about taking the project and changing this – alloisxp Aug 23 '19 at 07:43