0

I am very new to Laravel and my problems start at the running-my-application stage. For some reason I get this error when I try to access my application at http://127.0.0.1/test/public/ (I have Apache server):

ErrorException in EncryptionServiceProvider.php line 16:
Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'
in EncryptionServiceProvider.php line 16
at HandleExceptions->handleError('8', 'Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'', '/srv/http/test/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php', '16', array('app' => object(Application))) in EncryptionServiceProvider.php line 16
at EncryptionServiceProvider->Illuminate\Encryption\{closure}(object(Application), array()) in Container.php line 773
at Container->build(object(Closure), array()) in Container.php line 656
at Container->make('encrypter', array()) in Application.php line 613
at Application->make('Illuminate\Contracts\Encryption\Encrypter') in Container.php line 887
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 848
at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 813
at Container->build('Illuminate\Cookie\Middleware\EncryptCookies', array()) in Container.php line 656
at Container->make('Illuminate\Cookie\Middleware\EncryptCookies', array()) in Application.php line 613
at Application->make('Illuminate\Cookie\Middleware\EncryptCookies') in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 111
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53

I have mcrypt installed on my system:

[steelrat@archlinux test]$ php -m | grep mcrypt
mcrypt
[steelrat@archlinux test]$ php -i | grep mcrypt 
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

Moreover, when I start the artisan web server with php artisan serve and access it with http://localhost:8000, everything works fine. What can be the problem here?

I am aware of this topic: Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128' . But it doesn't look like my case. The problem with me is that it works with artisan serve and doesn't work with apache.

Community
  • 1
  • 1
stee1rat
  • 720
  • 2
  • 9
  • 20
  • 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](https://sourceforge.net/p/mcrypt/bugs/) dating back to 2003. Instead consider using [defuse](https://github.com/defuse/php-encryption) or [RNCryptor](https://github.com/RNCryptor), they provide a complete solution, are being maintained and is correct. – zaph Nov 22 '16 at 15:03
  • zaph, thanks for your answer. It is a dependency for Laravel, if I understand it correctly. I have no intention of using it. – stee1rat Nov 22 '16 at 18:56

1 Answers1

0

Depends on your system but there's usually separate php.ini for PHP CLI and PHP Apache.

Add the following to the top of public/index.php

<?php phpinfo(); exit;

That will tell you what extensions mod_php knows about and the location of your loaded php.ini

Richard Vanbergen
  • 1,904
  • 16
  • 29