Search code examples
phpmampfastcgiapc

Use APC with MAMP


I've installed on my MAC MAMP 3.0.2 and I used PHP 5.4.25 . This is my phpinfo:

enter image description here

I've already installed APC, and this is the APC page that MAMP show me:

enter image description here

I'm trying to run the follow php script:

<?php
$bar = 'BAR';
apc_store('foo', $bar);
var_dump(apc_fetch('foo'));
?>

but, when i run this script by command line I've the following error:

Fatal error: Call to undefined function apc_store() in /Users/xxxxxxxxx/htdocs/prova.php on line 3

What's wrong?

-- Thanks


Solution

  • When running PHP scripts from the CLI you will need to specify the PHP binary you want to use since by default php will be the default PHP included with OS X, not the one installed with MAMP.

    So instead of:

    user$ php script.php

    try:

    user$ /Applications/MAMP/bin/php script.php

    Obviously you will need to adjust the above with the path to where the MAMP PHP binary is located.