Use APC with MAMP - php

I've installed on my MAC MAMP 3.0.2 and I used PHP 5.4.25 .
This is my phpinfo:
I've already installed APC, and this is the APC page that MAMP show me:
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

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.

Related

how to add missing module tokenizer in list of php -m in Synology DSM 7 [duplicate]

When I attempt to run a PHP file containing mysqli functions through command line it throws an error like Fatal error: Uncaught Error: Call to undefined function mysqli_connect()
The same file runs perfectly through the built-in web station app so naturally, I tried running it with the -c parameter and specifying the same file that PHP is run with through the web station app:
php -c /usr/local/etc/php73/cli/php.ini /volume1/web/test.php
But I still get the same error so I am at a loss as to what the issue could be here
Synology Diskstation has a concept of packages. PHP packages are installed with a specific version number. When you want to use the same setup that you have in Web Station you must use the appropriate PHP version.
If you are using PHP 7.3 package then try executing it with php73
php73 /volume1/web/test.php

I'm getting php5.5 instead php7 when I run exec(php -v) in php script

When I run php -v in cli I get the exact php version 7, but when i run exec("php -v") in web server I get php 5.5 even thought in phpinfo i see that I am runing php 7?! Any idea why I get the older version of PHP?
running exec you get the CLI version of PHP
you probably installed php5.5 as CLI and php7 as apache module
If you use CentOs, add this line at the end of /etc/bashrc (or ~/.profile for Ubuntu)
export PATH=$PATH:/your/path/to/php7/bin
Then run:
source /etc/bashrc
P/s It may be better if you edit /etc/profile.d. Take a look both of them.
UPDATE
In MacOS, let edit ~/.bash_profile (create it if it does not exist) with the same content.

ImageMagick works in command line but when exec() in php it returns 5 with "incompatible library version"

I'm having a bizarre problem with php 5.3.6 and ImageMagick (command line) using MAMP (and Macports too..I tried both) on OS X.
When I run the identify command from the CLI, it works fine. But when I run the exact same command using exec(), it returns a value code of 5 and in the apache error logs I have:
dyld: Library not loaded: /opt/local/lib/libfreetype.6.dylib
Referenced from: /opt/local/bin/identify Reason: Incompatible
library version: identify requires version 14.0.0 or later, but
libfreetype.6.dylib provides version 13.0.0
E.g.
The cli command is:
/opt/local/bin/identify /Users/leonardteo/Documents/1.jpg
This works just fine when executed from the command line. When executed from PHP:
exec("/opt/local/bin/identify /Users/leonardteo/Documents/1.jpg", $output, $return);
$return is 5
$output is nothing
Checking the apache logs gives the above issue with libfreetype.
I installed ImageMagick using Macports. I've also tried a manual build from source and running identify from /usr/local/bin/identify and I get the same result. I have also tried running PHP from Macports instead of MAMP and I get the same result.
Could someone please help shed light on this?
Edit this file:
/Applications/MAMP/Library/bin/envvars
Comment out the following lines:
DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH

problem with PHP on console / MAMP after updating MACOSX

i've updated my MACOSX 10.6 and since then, i've not been able to use the PHP console version from MAMP.
php -v returns me 5.3.3 which is the PHP i've compiled and i want to use the one from MAMP
I've already done :
export PATH=$PATH:/Applications/MAMP/bin/php5.3/bin
and creating a .bash_profile and a .profile fileand i put in it : /Applications/MAMP/bin/php5.3/bin
without any results
echo $PATH returns :
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin
Did you reload the profile after altering .bash_profile?
source ~/.bash_profile
(or .profile if you use that one)

How do I get PHP to work with ADOdb and MySQL?

I'm trying to get a PHP site working in IIS on Windows Server with MySQL.
I'm getting this error…
Fatal error: Call to undefined function mysql_connect() in C:\inetpub...\adodb\drivers\adodb-mysql.inc.php on line 363
Update…
This link outlines the steps I followed to install PHP on my server:
How do I get PHP and MySQL working on IIS 7.0 ?
(note especially steps 6 and 8 regarting php.ini and php_mysql.dll).
Only two lines in the phpinfo report reference SQL:
<?php
phpinfo();
?>
Configure Command:
cscript /nologo configure.js "--enable-snapshot-build" "--enable-mysqlnd"
sql.safe_mode:
Local Value Off, Master Value Off
PHP Configure Command http://img79.imageshack.us/img79/2373/configurecommandmw8.gif
PHP sql.safe_mode http://img49.imageshack.us/img49/3066/sqlsafemoderu6.gif
Update…
I found the solution: How do I install MySQL modules within PHP?
Check out phpinfo to see if the mysql functions are compiled with your PHP
<?php
phpinfo();
?>
Since in some versions of php, its not default with the install.
Edit for the Update:
You should have a full MySQL category in your phpinfo();
See this for example: https://secure18.easycgi.com/phpinfo.php (googled example)
It sounds like the version of PHP you are using has not been compiled with MySQL support, or has not been enabled in the php.ini.
Looks like you haven't got the MySQL PHP extensions installed! You shouldn't have to do any configuration other than installing the correct modules (and shouldn't be doing anything with ADODB).
PHP comes in 2 versions as well - a CGI version and an ISAPI module. You're best using the ISAPI version with ISS and adding all the trimmings...
I found the solution: How do I install MySQL modules within PHP?

Categories