1

My environment:

  1. XAMPP Version 7.2.8
  2. PHP 7.2.8 (this was installed together when the XAMPP was installed.)
  3. Apache 2.4.34 (this was installed together when the XAMPP was installed.)

I am new to Laravel. I made Laravel project folder and executed the command php artisan key:generate to generate app_key.

but I got the error below:

PHP Warning:  PHP Startup: Unable to load dynamic library 'mcrypt' (tried: C:\xampp\php\ext\mcrypt, C:\xampp\php\ext\php_mcrypt.dll) in Unknown on line 0

I checked mcrypt is loaded by following code.

<?php
if(function_exists('mcrypt_encrypt')) {
    echo "mcrypt is loaded!";
} else {
    echo "mcrypt isn't loaded!";
}
?>

and it answered "mcrypt isn't loaded!".

So, I did as below following this instruction to add mcrypt.

I downloaded php-5.2.1-Win32 from this webpage. and copied libmcrypt.dll and php_mcrypt.dll in that php version to the ext folder in mine.

enter image description here

and I edited php.ini file as below.

enter image description here

for checking the location of php.ini, I use phpinfo().

enter image description here

and restarted Apache and tried to check if mcrypt is loaded by the program above. But the result was "mcrypt isn't loaded!".

I also tried to change the way to write in php.ini file as below:

enter image description here

but the result was the same: "mcrypt isn't loaded!".

I also tried to check if openssl is enabled by php -r "echo OPENSSL_VERSION_TEXT;". but the error occurred as follows:

Warning: PHP Startup: Unable to load dynamic library 'mcrypt' (tried: C:\xampp\php\ext\mcrypt

so, I commented out mcrypt extension in php.ini. "php -r "echo OPENSSL_VERSION_TEXT;"" worked resulting "OpenSSL 1.1.0h 27 Mar 2018".

Herbert
  • 540
  • 1
  • 6
  • 18
  • Can you check this is actually the php.ini being used? – Gabriel Alejandro López López Sep 23 '20 at 02:43
  • 1
    @GabrielA.LópezLópez for checking the location of php.ini, I use `phpinfo()` and refered to `Loaded Configuration File` part. – Herbert Sep 23 '20 at 02:48
  • Try with extension=php_mcrypt.dll according to https://www.php.net/manual/en/install.pecl.windows.php – Gabriel Alejandro López López Sep 23 '20 at 02:58
  • @GabrielA.LópezLópez I changed the way of writing with it as you advised. But still, mcrypt isn't loaded. – Herbert Sep 23 '20 at 03:23
  • Sorry I can't help you then. Steps are un comment or write extension name and restart Apache. The other thing to check is if extensions are being stored where php.ini is defining. Check this but in xampp is not a common issue – Gabriel Alejandro López López Sep 23 '20 at 03:42
  • @GabrielA.LópezLópez I checked the result of `phpinfo()` for the location for extention folder. Thank you for your help anyway! – Herbert Sep 23 '20 at 04:10
  • Does this answer your question? [PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so'](https://stackoverflow.com/questions/49931694/php-warning-php-startup-unable-to-load-dynamic-library-mcrypt-so) – AmirAli Esteki Sep 23 '20 at 04:12
  • mcrypt is not in the php-7.2 zip package so I wonder what version of php did you get that extension from. Anyway, have you checked if openssl is enabled? `php -r "echo OPENSSL_VERSION_TEXT;"` You might want to check https://laravel.com/docs/8.x/installation#server-requirements for server requirements. – Chester M Sep 23 '20 at 04:13
  • @TeyM I use `php-5.2.1-Win32`. I copied nessesary files and pasted them in my php extention folder as [this instruction](http://www.myoddweb.com/2010/11/18/install-mcrypt-for-php-on-windows/); – Herbert Sep 23 '20 at 05:09
  • @TeyM I did "php -r "echo OPENSSL_VERSION_TEXT;"" but error occurred. I added about this in OP. – Herbert Sep 23 '20 at 05:17
  • I don't think that will work man. You're using a different version of php. [mcrypt was removed from core php and moved to PECL instead](https://www.php.net/manual/en/migration71.deprecated.php). I was just wondering why laravel would throw an error like that since mcrypt isn't a requirement for it to run. – Chester M Sep 23 '20 at 05:27
  • try to comment out mcrypt extension in your php.ini then try again – Chester M Sep 23 '20 at 05:28
  • if nothing works I suggest, since you're on Windows, use [laragon](https://laragon.org/) instead of xampp. It's easy to switch php versions and enable extensions there along with some other tools. – Chester M Sep 23 '20 at 05:30
  • @TeyM Laragon looks good. I will look into it. Thanks! – Herbert Sep 23 '20 at 06:03
  • @TeyM I commented out mcrypt extension in php.ini. "php -r "echo OPENSSL_VERSION_TEXT;"" worked resulting "OpenSSL 1.1.0h 27 Mar 2018". – Herbert Sep 23 '20 at 06:06

1 Answers1

2

you have probably installed 7.2 Non Thread Safe (NTS) x64 <-- mcrypt zip. Try installing 7.2 Thread Safe (TS) x64 and make necessary file changes.