6

The problem:

I have installed Composer and followed the Quick start guide in the Laravel 4 documentation.

I get the following error when I run composer install or composer update:

Script php artisan optimize handling the post-install-cmd event
returned with an error...

I tried to run the following composer command:

composer create-project laravel/laravel myproject --prefer-dist

Or use their laravel.phar:

laravel new myproject

Or get the zip version from git: https://github.com/laravel/laravel?source=c

And I still fail to update via composer.


Additional information:

My PHP version on my Mac is:

PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, 
Copyright (c) 1998-2013 Zend Technologies

PHP version on MAMP: 5.4.10

I found some solutions on Google / Stack Overflow but those did not work well in my case.

3 Answers 3

5

It says:

MCrypt PHP extension required

So it looks like you're missing the Mcrypt extension, which is required by Laravel (actually, I think it's used only by the Authentication class for password handling, not for the rest of the components of the framework).

I haven't got a Mac, but the command to install it should be something like this, using Homebrew

brew tap josegonzalez/php
brew install mcrypt php54-mcrypt

These links might help you:

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your answer @Damien Pirsy. I tried to install mcrypt via Homebrew but I dunno how to check my installation. The error is still here.
Did you restarted the server?
Thanks for you tips @Damien Pirsy. I found a new instruction of installing mcrypt on OSX 10.9 and it works. Now the error has gone!
Follow this link for the correct installation of mcrypt for OSX 10.9: coolestguidesontheplanet.com/…
The error Script php artisan optimize handling the post-install-cmd event returned with an error due to MCrypt PHP extension required?
1

Having the setting xdebug.scream = 1 in the configuration was the cause of the problem for me. I fixed it by doing the following:

  1. Find XDebug configuration file.

    $ sudo find / -name xdebug.ini
    
  2. Edit file using any text editor.

    $ sudo vi /your_path/xdebug.ini
    
  3. Set xdebug.scream = 0

  4. Reload the server (Apache/Nginx/whatever).

    $ sudo service nginx reload
    

Comments

0

You might have Mcrypt installed already on your computer, if you are using MAMP or any other application. So, you don't need to install Mcrypt again. Add the following code to a php file and place it in your htdocs directory. See the info about the PHP you are running. You can see whether Mcrypt is already installed or not.

<?php
phpinfo();

If it shows Mcript, then do the following:

  • Check which PHP version you are using. You can see different directories for different PHP versions in this directory: /Applications/MAMP/bin/php/.
  • Move to the user's home directory. Use this command on terminal: cd ~.
  • Edit (or create a new one if not exists) .bash_profile file.
  • Add the following line:

where php5.5.10 is the directory of the PHP version you are using.

export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:$PATH

Now restart your computer. And you can use php artisan command of Laravel.

Source of information: Laravel requires the Mcrypt PHP extension

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.