Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 491
rogdawg Avatar asked Mar 15 '15 02:03

rogdawg


People also ask

How do I enable mcrypt extension?

You can install Mcrypt from the PHP Source Tree as a module if you choose. Enable the module by adding: 'extension=mcrypt.so' to PHP. ini. Done!

Does laravel require mcrypt?

Laravel does not need mcrypt extension anymore. The best (=secure) solution is to update to Laravel >5.1 (there is no LTS before Laravel 5.2).

What is mcrypt extension?

The mcrypt extension is an interface to the mcrypt cryptography library. This extension is useful for allowing PHP code using mcrypt to run on PHP 7.2+. The mcrypt extension is included in PHP 5.4 through PHP 7.1.

How do I know if mcrypt is enabled?

You can also achieve this same screen by viewing a php file that has: phpinfo(); somewhere in the code. In this screen, simply search for the string "mcrypt support". If installed, you will see a box that says "enabled".


2 Answers

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

like image 67
Raynal Gobel Avatar answered Oct 22 '22 04:10

Raynal Gobel


mac users install brew and then enter

brew install php56-mcrypt

in terminal

EDIT

if you get any error using above line then try this command

brew install homebrew/php/php56-mcrypt
like image 5
Muneef M Avatar answered Oct 22 '22 04:10

Muneef M