can't create a Laravel project because mcrypt extension is missing

rogdawg picture rogdawg · Mar 15, 2015 · Viewed 18.8k times · Source

OK, I have seen many posts about this, and I have spent the entire day working through them to solve this issue, with no success.

I am trying to create a Laravel project. I am using a Mac (Yosemite), which is running PHP 5.5.14. There is also an older version of PHP on the machine. When I try to create a project from the command line using "laravel new projectname", no errors are reported, but the command just creates an empty folder named with the project name. I get the "Crafting application..." and "Application ready! Build something amazing" messages but, again, only an empty folder.

If I try to use this command: composer create-project laravel/laravel projectname

I get this:

Installing laravel/laravel (v5.0.16) - Installing laravel/laravel (v5.0.16) Downloading: 100%

Created project in projectname Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Your requirements could not be resolved to an installable set of packages.

Problem 1 - Installation request for laravel/framework v5.0.16 -> satisfiable by laravel/framework[v5.0.16]. - laravel/framework v5.0.16 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.

In the terminal, if I enter this: which php I get: /usr/bin/php /usr/bin/php -v I get: PHP 5.5.14 (cli) (built: Sep 9 2014 19:09:25) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

I used homebrew to install autoconf and mcrypt with this command: brew install autoconf mcrypt

If I run that command again, I get: Warning: autoconf-2.69 already installed Warning: mcrypt-2.6.8 already installed

Since I kept getting the error, I assumed it was installed in the wrong place so, I compiled and installed mcrypt myself using these instructions: [Install mcrypt php extension][1]. I used PHP version 5.5.14 during the install. Mcrypt was installed in this directory: /usr/lib/php/extensions/no-debug-non-zts-20121212/

I have restarted Apache. I have checked my .bash_profile to make sure /usr/bin is in my Path.

If I create a page with phpinfo() and view it in my browser, I see that mcrypt is listed in the "Module Authors" section of the page. It just lists the names of the people who created the module.

I am stumped. I look forward to any suggestions that people might offer (I really don't want to install a virtual box, or anything like that. Surely, I can get this module installed in the right place!)

Thanks very much!

Answer

Raynal Gobel picture Raynal Gobel · Mar 26, 2015

I got this exact same problem too. You have to find php.ini for php cli and add extension=mcrypt.so

My system is running LAMPP server with preinstalled PHP. So, here's what I do:

Install mcrypt extension

I tried both:

sudo apt-get install mcrypt
sudo apt-get install php5-mcrypt

Configure php.ini for CLI

Then, edit php.ini located in /opt/lampp/etc/php5/cli/php.ini add extension=mcrypt.so on Dynamic Extension section (anywhere is fine I think). Don't forget to restart your server.

Try using composer to install laravel

Now, you can run whatever method you want to install laravel. I download Laravel 5 manually, unzip, then install using composer install command. I think your command composer create-project laravel/laravel projectname would've run smoothly too.

References: here