While crafting a new Laravel application, I encountered the following PHP error:
Use of undefined constant MCRYPT_RIJNDAEL_128
Like what any good Geekysaur would do, I checked my server’s PHP configuration. At first glance, one would think that there’s an error in the code and this specific variable has just not been defined. Looking at the PHP configuration though (you could take a peek using phpinfo()), you would notice that the MCRYPT module has not been installed or enabled.
So what do we do? We have to install that module of course! To do that, just run the following:
# If you have not installed it yet.
sudo apt-get install php5-mcrypt
# We have to enable the module after installation as it's not being done by default.
sudo php5enmod mcrypt
# Then we just have to restart Apache.
sudo service apache2 restart
# Or sudo service nginx restart if using nginx.
That’s it! You shouldn’t have any problem installing Laravel or seeing this issue on your web application.
Did this solve your problem? Do you have other ways or suggestions on making the solution better? Hit us up on the comments below!