3

I know there are a lot of questions about this on SO but none of them address my problem. I've checked everything they mention everything seems to indicate mcrypt is ok except when installing Laravel. Clearly I'm missing something.

When installing Laravel as directed (composer create-project laravel/laravel myproj --prefer-dist) I get the error "Mcrypt PHP extension required" at what seems to be near the end of installation.

As far as I can tell mcrypt is installed and enabled.

Composer uses /usr/bin/env php

$ which composer       
/usr/local/bin/composer

$ cat /usr/local/bin/composer
#!/usr/bin/env bash
/usr/bin/env php -d allow_url_fopen=On -d detect_unicode=Off /usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar $*%   

php on my PATH is 5.5.10 from MAMP

$ php --version
PHP 5.5.10 (cli) (built: Apr 10 2014 17:49:22)

$ which php
/Applications/MAMP/bin/php/php5.5.10/bin/php   

Mcrypt is installed and enabled

$ php -m | grep mcrypt
mcrypt

$ php --info | grep mcrypt                  
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value

$ php --ini                                 
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.5.10/conf
Loaded Configuration File:         /Applications/MAMP/bin/php/php5.5.10/conf/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

$grep mcrypt /Applications/MAMP/bin/php/php5.5.10/conf/php.ini      
extension=mcrypt.so

I can see mcrypt support enabled in a phpinfo page via MAMP too.

What am I missing?

edit: I have export PATH="/Applications/MAMP/bin/php/php5.5.10/bin:$PATH" in .bash_profile and can confirm with echo $PATH and which php

update: a clue.

If I edit /usr/local/bin/composer to be:

#!/usr/bin/env bash
echo $PATH
/usr/bin/env php --ini

and run composer I get

/usr/bin:/bin:/usr/sbin:/sbin
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         (none)
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed:      (none)

Why is that PATH different?

12
  • Might be a long-shot but is the mcrypt.so file in the configured extensions directory? Commented Jul 29, 2014 at 1:23
  • 1
    Check laravel.io/forum/…. Composer may still be using the system PHP binary (due to /usr/bin/env php) Commented Jul 29, 2014 at 1:25
  • Yes and yes. I can see mcrypt.so in the dir that's specified in the ini and I have the MAMP php bin folder on my path (see edit) Commented Jul 29, 2014 at 1:33
  • Wait a sec... Everything above your edit uses /Applications/MAMP/bin/php/php5.5.10 yet your PATH contains /Applications/MAMP/bin/php/php5.4.19. I'd say that's your problem. Upgraded MAMP recently? Commented Jul 29, 2014 at 1:39
  • 1
    I'm totally at a loss. This is why I use Vagrant on the mac Commented Jul 29, 2014 at 4:20

4 Answers 4

6

Getting Laravel working on Apache

PHP version : PHP 5.5.9

Ubuntu version : 14.04

After a lot of trial and error and searching around , this is what i discovered . i had a working laravel project on windows, i copied it to ubuntu server and started getting the mcrypt error.

getting artisan command working

i did a lot of trial and error so each time i run the php5enmod command before, i had error messages. but on fresh install there was no error messages. after this step i got artisan command working

sudo rm /etc/php5/mods-available/mcrypt.ini
sudo apt-get purge php5-mcrypt
sudo apt-get install mcrypt
sudo apt-get install php5-mcrypt
sudo php5enmod mcrypt

fixing the browser error

sudo nano /etc/php5/apache2/php.ini

add the following line under the dynamically compiled extensions section of php ini

extension=mcrypt.so

restart the apache server , purge the laravel cache and everything working

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

1 Comment

How does one "purge the laravel cache"?
1

From what you've posted, it looks like composer is using a different PHP installation than your MAMP version. One workaround would be using the PHAR version instead:

wget https://getcomposer.org/composer.phar
php composer.phar create-project laravel/laravel myproj --prefer-dist

If your CLI php is registering mcrypt as an installed module, this will resolve your installation issue.

3 Comments

You'd think so, but even that doesn't work (same error).
@Jake - Do you have libmcrypt installed? Have you verified that you're able to run the mcrypt functions via the CLI?
@SamDufel Good idea. Something like php -r 'echo MCRYPT_ENCRYPT, PHP_EOL;' should suffice (result should be 0)
0

The only thing I can find to make this work is to edit /usr/local/bin/composer and set the PATH in there like so:

#!/usr/bin/env bash
export PATH="/Applications/MAMP/bin/php/php5.5.10/bin:$PATH"
/usr/bin/env php -d allow_url_fopen=On -d detect_unicode=Off /usr/local/Cellar/composer/1.0.0-alpha8/libexec/composer.phar $*

It's hacky and I'd still like to know what's up with my env but it works!

Comments

0

i had also encounter similar problem, and following command worked for me.

sudo apt-get install php5-mcrypt

Hope it will works your too.

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.