I am trying to execute a php file with a specific MAMP php version(/Applications/MAMP/bin/php/php5.3.14/bin/php) . But even though I have enabled APC caching while starting MAMP, apc code are getting error like "Fatal error: Call to undefined function apc_fetch()" . in general running of that script from browser via 'localhost' works fine.
I have also tried by adding 'apc.so' to php.ini file for that php version. But this is generating another error 'Segmentation fault: 11' .
What can I do to get the APC running under that php cli version please? Thanks.
MAMP uses a different php.ini for CLI. Here's how to find it:
$ php -i | grep 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
In this case you should edit /Applications/MAMP/bin/php/php5.5.10/conf/php.ini and uncomment:
;extension=apcu.so
EDIT: make sure php is the MAMP php and not system php! In doubt use:
$ /Applications/MAMP/bin/php/php5.5.10/bin/php -i | grep php.ini
Related
I'm trying to enable memcached on my file server. I have added the line 'memcached.use_sasl = 1' in my php.ini file, and restarted apache2.
A phpinfo(); command shows that memcached.usesasl is set to 1.
However, whenever I run a php artisan command I get the following error message:
Memcached::setSaslAuthData(): SASL support (memcached.use_sasl) isn't enabled in php.ini
I made sure to run the phpinfo() from within my laravel projects public/index.php to make sure that I was looking at the configuration that Laravel is using (just in case it was using a different php somehow?) and it shows memcached.use_sasl is set to 1.
Apache-embedded PHP and command-line PHP often use separate ini files. Check for php-cli.ini in the same dir as php.ini. You can also run php --ini and it will show what files it uses.
I get this error when I try to run test cases that need ionCube:
The file path/to/file.php has been encoded with the ionCube PHP Encoder and requires the free ioncube_loader_lin_5.4.so ionCube PHP Loader to be installed.
Fatal error occurred in test case Class_Name->testCaseName.
TearDown for fatal-error-failed-test and tearDownAfterClass were successfully called after fatal error occurred.
I have PHPUnit 4.5.0.
ionCube is installed correctly as I can see it with phpinfo() and the website is working.
PHPUnit may be using a different php.ini file than your website, so you'll see the ionCube Loader on a webpage generated by <?php phpinfo();.
To confirm, type in php -i to see the CLI version of phpinfo() (or php -i | grep -i ioncube to see if the ionCube Loader is installed, and php -i | grep "Loaded Configuration File" to see where your CLI PHP configuration file lives).
Do note that PHPUnit may be using a completely different php.ini file still - you'll have to look into your own setup for more details.
Once you've located the configuration file, you should be able to copy and paste the zend_extension line from your working php.ini file, provided you have the same PHP setups for both CLI and CGI.
If you're stuck and/or it's still not working, you can also create a ticket at ionCube's Helpdesk.
I run MAMP on my Mac at home, but on my work machine (Win7) I just started using MAMP for Windows so that I'm running the same (relatively speaking) software between the two machines. I was running some commands from the command line yesterday and noticed that the script was throwing errors because the mbstring extension wasn't loaded. I did some digging and am left scratching my head now...
In the browser, everything works fine. When I check the phpinfo, it's loading the configuration file just fine and mbstring is enabled. When I switch to the command line though, mbstring isn't in the list of modules (php -m). Also, when I do a php --ini, it tells me that no configuration file was loaded. I've added the correct PHP version to my PATH and running php -v gives me the version I expect, so I'm not really sure why PHP on the command line is acting differently from PHP in the browser.
Has anyone run into this before? How do I make PHP on the command line load the same configuration file that the browser is using?
Command line php (CLI) is a different executable to CGI PHP. It also uses typically a different php.ini file. You can however specify the location of the php.ini you would like to load when launching php cli:
php -c <path to your php.ini>
Have a look here.
This example assumes you use C:\MAMP\ as installation directory.
As you need configuration as used in Windows MAMP you will need to supply it as argument to php.
Open command prompt.
To execute test.php with script located in C:\MAMP\htdocs\ by using PHP5.6.0 from MAMP:
C:\MAMP\bin\php\php5.6.0\php.exe -c "C:\MAMP\conf\php5.6.0\php.ini" "C:\MAMP\htdocs\test.php"
As you can notice last argument is the script to be executed ("C:\MAMP\htdocs\test.php").
To execute phpinfo from command line:
C:\MAMP\bin\php\php5.6.0\php.exe -c "C:\MAMP\conf\php5.6.0\php.ini" -r phpinfo();
There should be line from phpinfo output which acknowledges that you're using configuration from C:\MAMP\conf\php5.6.0\php.ini.
Loaded Configuration File => C:\MAMP\conf\php5.6.0\php.ini
I have a PHP that downloads files from backend. I am using WAMP in Windows 7 and it works perfectly when done through the browser.
Now I have created a batch file to execute the php and it shows:
Fatal error: Call to undefined function curl_init()
Not sure why something that could work over in browser is not working in batch file. Below is my code for the batch file:
#ECHO OFF
php.exe -f "C:\wamp\www\test\test.php"
Any idea what's the issue?
uncomment the following on your php.ini
;extension=php_curl.dll
and restart webserver. This might be due to curl disabled in your php.
When you use wamp, xamp or other all-in-one server, it uses an overrided php.ini located into bin/conf/ instead where original is.
You need copy from these or edit the ini located at php.exe folder.
If you cant access it (shared server, etc), you can create a custom php.ini file into script folder, and put needed instructions:
extension_dir = "c:/wamp/bin/php/php5.3.5/ext/" // change version if needed to yours
extension = php_curl.dll
When using through browser it is using WAMP and the PHP ini is from C:\wamp\bin\php\php5.4.3
But I have set my php directory to C:\php-5.4.9 in environmental variables, thus when using windows batch it is calling php from that directory and there was no php.ini file there.
I copied the PHP ini file from wamp to php folder and now it is working.
Apparently I have installed php and then wamp, thus there is a overlap which has caused confusion.
My problem was that my environment was not complete... then i just install php5-curl:
sudo apt-get install php5-curl
restart server
I'm want to start using phpDocumentor and the manual installation keeps throwing an error about me not having set detect_unicode = Off in my php.ini in Terminal.
When I add it to my php.ini it doesn't take and I get the same issue when running the install. Nobody seems to have this problem, and for the life of me I can't figure it out.
https://github.com/phpDocumentor/phpDocumentor2/blob/develop/README.md#installation
What am I missing? (I did restart the MAMP server after the php.ini edit)
Screenshot of the error in terminal...
If you have MAMP/MAMP Pro installed then the problem is that the PHP version available to your terminal will most probably be the system version located in:
/private/etc/
I had the same problem but in my case I didn't have a php.ini file in that directory so the best way to resolve it is to just create a symbolic link to the PHP version currently in use in your MAMP/MAMP Pro installation:
php.ini -> /Applications/MAMP/bin/php/php5.3.14/conf/php.ini
That solves the issue. Just change the php version php5.3.14 to whatever version of PHP you've selected to use in MAMP.
As #moderndegree mentions above, you can then optionally make this available to the terminal in the future by editing your path variable in your bash/zsh/etc:
export PATH="/Applications/MAMP/bin/php/php5.3.14/bin:$PATH"
You must not be editing the right php.ini if it still is enabled. Run php -i | grep ini to find all the ini files that are loaded.
The relevant lines are those two:
Loaded Configuration File => ...
Additional .ini files parsed => ...
The problem is that you are probably hitting a different php install.
Try the following:
which php
If you get anything other than, /Applications/MAMP/bin/..., you need update your environment to point to MAMP's installation.
To do this, you will need to add the following to .bash_profile (please update the path to match your setup):
export PATH="/Applications/MAMP/bin/php/php5.3.6/bin:$PATH"
Reload .bash_profile with the following command:
source .bash_profile
After you do this, you should be pointing to the correct php installation. Try which php again to confirm. Now run php -i | grep ini to confirm that the correct php.ini file is being loaded. As Seldaek stated, the relevant lines are:
Loaded Configuration File => ...
Additional .ini files parsed => ...
As I remember, MAMP uses configuration templates. So you should edit php.ini template. The actual php.ini will be regenerated from the template everytime you restart MAMP.
I faced the same problem for composer-php and i add this line manually into php.ini file. Like this:
sudo /private/etc/php.ini
then add this line "detect_unicode = Off"
detect_unicode = Off
then its work and i installed composer. You can see this
How to disable "detect_unicode" setting from php.ini? (trying to install Composer)
If you can't change your /usr/local/bin/php/php.ini file, remember to keep using '-d detect_unicode=Off' for all your php calls like so:
curl -s https://getcomposer.org/installer | php -d detect_unicode=Off
php -d detect_unicode=Off composer.phar install
If you are able to change your php.ini file, then add the following to the end of your php.ini:
detect_unicode = Off