Alecaddd | Designer Developer Dreamer

Web Design and Development, Digital Painting, Music and Life

  • Who
  • What
  • Uses
  • Blog
Posted in Tutorials

How to solve the “Mcrypt PHP extension required” problem during the Laravel installation

So, you decided to start using/study Laravel? Good!

When it comes to learn or practice with something new the most frustrating part is when this new “toy” won’t work out of the box. And that’s what happened to me the first time I tried to install Laravel on my MacBook Pro. I struggled with this problem for a good hour before finally figuring out what was wrong, and I thought would be great to write it down for future installations or to help other dudes like me that could encounter this problem. So, let’s take a look.

 

First step, before even start

Before even try to install Laravel you have to be sure that your machine has PHP and a Server Apache installed on it. The easiest way is to download MAMP and let him install everything for us, like PHP, Apache and MySql, something that you’ll need for sure if you’re intended to build something with Laravel.

Also, remember to install Composer to manage all the dependency of PHP and help you out a lot with Laravel, but not only.

 

Install Laravel

Open your Terminal and navigate to your favourite folder, the one you decided to use for your Laravel installation
cd /your-directory/your-folder
Always inside the Terminal write this code to activate Composer and tell him to download and install the latest version of Laravel for us
composer create-project laravel/laravel your-project-name --prefer-dist
And here comes the pain! This is the point where I got the current error message
Mcrypt PHP extension required.
Script php artisan clear-compiled handling the post-install-cmd event returned with an error.
[RuntimeException]
Error Output:
create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repository-url="..."] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [package] [directory] [version]

So, why is this happening? I’m not totally sure about the reason, but it looks like that Composer is trying to use the PHP version installed in the OS and not the one installed with MAMP, that it comes with the necessary Mcrypt extension.

 

Solve the problem

To solve this problem we have to edit our .bash_profile script and create an export to our MAMP php version. First of all open another Terminal instance and check your current php version with the command:
php -v
Your result should be something like this
PHP 5.5.10 (cli) (built: Apr 10 2014 17:49:22)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

Now that we have our PHP version, in my case 5.5.10, we can open our .bash_profile script
nano .bash_profile
and add our MAMP PHP version after the code already present
export MAMP_PHP=/Applications/MAMP/bin/php/php5.5.10/bin
export PATH="$MAMP_PHP:$PATH"

Exit the file and Save it. That’s it!

Now, if you run again the Composer command inside your folder, the installation should successfully complete.

Hope to be helpful to someone, see ya!

 

Posted on June 17, 2014June 19, 2014
  • Twitter
  • Facebook
  • Reddit
  • Pinterest
My Birthday in Seattle
WordPress 101: WordPress for beginner developers

Recent Posts

  • Thunderbird Development – Implementing Customizable Shortcuts September 4, 2024
  • Featured image of windows loval web development setupEasiest Windows Development Setup – WordPress, Laravel, NodeJS in 5 minutes May 15, 2022
  • We are the generation of forced nostalgia March 27, 2022
  • Working on Thunderbird. UX and UI challenges of an Open Source project. February 23, 2021
  • XP-Pen Artist 12 Pro Review and International Giveaway! January 14, 2020

Podcast Episodes

  • Episode 44 – The Nerds are back! May 18, 2020
  • Episode 43 – This is awkward…getting settled into your new role May 12, 2019
  • Episode 42 – We need to talk about Gutenberg Development Workflow… February 24, 2019
  • Episode 41 – You’re not a real developer, unless… February 18, 2019

Categories

  • Coding 1
  • Reviews 8
  • Tutorials 12
  • Updates 18