1

I have a following problem - when using phpunit in my Laravel 4 installation folder I get a following error:

Laravel requires the Mcrypt PHP extension.

However it does not appear when I'm using the artisan command. I know that the issue must be caused by phpunit loading another php.ini than the one set in my zshconfig.

Unfortunately I don't know how to force phpunit to use the correct one.

My .zshconfig looks like this:

# Customize to your needs...
export PATH=:/Applications/MAMP/Library/bin/:/Users/jacekbandura/pear/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin/:/Users/jacekbandura/nasm

export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

I'm using OS X 10.8.4 and MAMP.

Has anyone solved this problem before? Thanks in advance :)

jban
  • 149
  • 1
  • 10
  • It might be running your mac's default PHP executable (`/usr/bin/env php`) rather than simply loading in the wrong php.ini file. Does your custom path include the path to php executable (what gets called when running php on CLI) or just php.ini? – fideloper Sep 09 '13 at 13:09
  • how can I check it? I've posted .zshconfig content. I've tried to add `/Applications/MAMP/bin/php/php5.4.10/bin/php` but it doesn't seem to help. – jban Sep 09 '13 at 15:20
  • Is this when you run phpunit manually in Terminal, or is it automated in any way? You can, if you choose, edit the phpunit executable directly and replace `#!/usr/bin/env php` with `#!/Applications/MAMP/bin/php/php5.4.10/bin/php`. Not the most recommended course of action... – fideloper Sep 09 '13 at 16:07
  • Sidenote: For future projects, consider using Vagrant or another virtual machine, so you don't have to work with PHP and other binaries on non-standard locations (developing directly on your mac is a pain for almost *everything*). – fideloper Sep 09 '13 at 16:08

1 Answers1

2

Here are some install notes from PHPUnit and an article. Did you install phpunit via composer? Or did you install it another way?

Here are some install directions, hopefully one matches your use case.

PhpUnit docs point towards editing a phpunit file and setting the path to the php binary directly

This article points towards installing PhpUnit with PECL and shows taking a setp to change the PHP executable you'll be using

This SO answer points towards using Composer, but setting some specific config

Community
  • 1
  • 1
fideloper
  • 12,213
  • 1
  • 41
  • 38
  • 1
    Installing phpunit via composer solved my problem. I completely forgot about this way of using phpunit. Thanks :) – jban Sep 09 '13 at 20:36