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?