3

I've hit a roadblock with my phpunit functional tests. The AWS SDK requires APC, for some reason I can't get phpunit to load the extension. I'm not sure where I'm going wrong. The CLI is using the same ini file as MAMP

Gregs-MacBook-Pro:HvH-PHP greg$ php --ini
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.3.6/conf
Loaded Configuration File:         /Applications/MAMP/bin/php/php5.3.6/conf/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)
Gregs-MacBook-Pro:HvH-PHP greg$ 

I've also attempted to add the ini file into app/phpunit.xml.dist

<php>
    <ini name="mamp" value="/Applications/MAMP/bin/php/php5.3.6/conf/php.ini"/>
    <server name="KERNEL_DIR" value="app/" />
</php>

Error message in CLI

PHP Fatal error:  Call to undefined function apc_fetch() in /vendor/aws-sdk-for-php/lib/cachecore/cacheapc.class.php on line 58

EDIT: Some more test as per comments In CLI I can run a test script with apc_fetch(); and it works successfully.

Running php -m also shows APC as an installed module

Any suggestions as to what else I should try?

greg
  • 6,853
  • 15
  • 58
  • 71
  • `php -i |grep -i apc` and/or `php -m` – zerkms Jul 17 '12 at 22:29
  • first command returned a bunch of APC info, all looks good. Here are the first four lines: `apc APC Support => disabled APC Debugging => Disabled apc.cache_by_default => On => On apc.canonicalize => On => On` – greg Jul 17 '12 at 22:33
  • php -m also shows APC: `php -m [PHP Modules] apc ` – greg Jul 17 '12 at 22:34
  • what if you create script ` – zerkms Jul 17 '12 at 22:42
  • works fine, i tried with that and did not get a response, then tried again with a deliberately miss-spelt version and i got the error. – greg Jul 17 '12 at 22:53
  • So what and how do you run? How is it different from `php -f testscript.php`? – zerkms Jul 17 '12 at 22:55
  • what if you put `var_dump(get_loaded_extensions()); exit;` in any phpunit test and check if there is APC loaded when you run phpunit? If not - replace it with `phpinfo();` and check what config file has been loaded – zerkms Jul 17 '12 at 22:58
  • ahh good call. That's the problem it's not using the MAMP ini file. How do I tell phpunit to use that ini file? I thought I have already specified that in the params xml (see question) Configuration File (php.ini) Path: /etc Loaded Configuration File: /private/etc/php.ini – greg Jul 17 '12 at 23:05
  • Uhm, that's strange. Where `/private/etc/php.ini` comes from? On my installation I have the same ini-file loaded for generic CLI run and phpunit – zerkms Jul 17 '12 at 23:17
  • hrmmm. I guess that ini file is the generic osx file. I use mamp and I originally had to update my .profile to add the mamp php.ini onto the path var so I could us it in cli. – greg Jul 17 '12 at 23:22
  • as a temporary solution you could create a symlink of `/Applications/MAMP/bin/php/php5.3.6/conf/php.ini` to `/private/etc/php.ini`, because I cannot find possibility of specifying ini-file for phpunit explicitly – zerkms Jul 17 '12 at 23:24

1 Answers1

2

I could propose you 2 solutions:

  1. Create a symlink of /Applications/MAMP/bin/php/php5.3.6/conf/php.ini to /private/etc/php.ini

  2. Modify phpunit execution file and append -c /Applications/MAMP/bin/php/php5.3.6/conf/ to the php run command. Also - check if correct php binary is used. If it is not - change to the correct path first and check if issue has been fixed

zerkms
  • 249,484
  • 69
  • 436
  • 539