I would like to use MAMP's version of PHP for my local PHP testing and development. I understand that Macs come with a version of PHP installed. I have installed MAMP and everything seems to be going smoothly except error reporting.
In Terminal I have checke which version of PHP my machine is using and it is not the one from MAMP. I have changed MAMP's php.ini files to report all errors. I am not getting any errors in my testing. I am inserting obvious errors to test for.
My questions are:
How can I disable or remove the preinstalled version of PHP?
How can I set my machine to use only MAMP's version of PHP?
Can I test multiple versions of PHP at once? Is it recommended?
How can I stay up to date with the latest version of PHP? Is it like normal Software Updates?
-Josh
Add/change following line in ~/.profile or ~/.bashrc (for bash):
export
PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.2.17/bin:/usr/local/bin:$PATH:/opt/local/bin
and after that please re-login (or just execute e.g. /bin/bash).
From http://drupal.org/node/1464236
You can change the version # to the version you want.
Related
At the moment I'm using two machines for Web (Win10) & iOS development (MacOS) and looking to combine them into a one computer that I would use on a daily basis.
My current challenge is to ensure that I can develop and run two or more environments on the same machine (not necessary at the same time, a simple switch would do the job).
I've tried MAMP and AMPPS and they both do the job, with an exception to the PHP-CLI version.
Every time I run php from the console it opens up the latest version completely ignoring the one that is specified by the MAMP or AMPPS.
What is the best way to ensure that php-cli always points to a currently active version of the PHP as stipulated by MAMP or AMPPS?
On Windows I was using https://ospanel.io/ that had it's own internal terminal window that would automatically load the current version of php-cli.
I am fully aware of docker/vagrant but they would be an overkill in this case.
Thanks
Unfortunately there is no simple answer to my question. As a solution:
Get multiple version installed
Design a script that changes the PATH environment to the right version as required.
alternatively a script that rewrites a symlink to a required version of the PHP.
For MAMP user, you must edit the file /usr/local/etc/httpd/httpd.conf and set the PHP version you prefer to use in your stack. I only installed one version of Apache HTTPD with multiple PHP versions - you have to specify the version.
If you don't, the default is the Mac's pre-installed PHP version.
I have the latest version of Apache (Apache 2.4), latest version of PHP (PHP7), and latest version of MySQL (not sure the version but I have WorkBench version 6.3). In the past, when I checked if my PHP was working by this line of code <?php phpinfo(); ?> it would show that I have MySQL / mysqli installed and ready to go. But with PHP7 it shows mysqlnd.
I try using mysqli commands to check if I can connect to my database by mysqli_ping() and I also tried connecting to the database using server, user, pass. I keep getting errors such as Class mysqli not found. Or Call to undefined function mysqli_ping(). I've tried searching the net for some answers and All I could find was that I need to install MySQL (but a few sites said it was deprecated).
Am I able to get mysqli for PHP7? Or do I use mysqlnd? What is mysqlnd? Is it a new version of MySQL/mysqli?
Update 2020
For Windows 10 users I strongly recommend windows subsystem for linux (WSL 2) and setup your server there.
If you need php and mysql access in windows environment, then the fastest way is to install Wampserver. If you also need access to php through console then add php location (like C:\wamp64\bin\php\php7.4.11) to environment variables.
If that doesn't suit you and you need full setup always enabled on your system then follow install with choco.
To work properly with apache and load all needed extensions (including php_mysqli) you need ThreadSafe version of PHP, so make sure to download correct version or if you use Chocolatey to manage your windows applications, then just install php with this command:
choco install php --package-parameters='"/ThreadSafe "'.
This will install php in C:\tools\php72 directory, but you can overwrite it with another parameter:
choco install php --package-parameters='"/ThreadSafe ""/InstallDir:C:\PHP"""'.
The mysqlnd extension is part of PHP. It was developed as an alternative to bundling the libmysqlclient, because that library had license conditions that made it awkward to bundle with PHP.
You won't use mysqlnd directly. It's an internal library that is used by mysqli and pdo_mysql as a means to communicate with the MySQL Server.
As for mysqli, yes, it's available for PHP 7. I don't use Windows, but apparently not all extensions are enabled by default.
You probably need to edit your php.ini and uncomment the line
extension=ext_mysqli.dll
or whatever it is for that extension. It might already be in the file, but commented out. So go take a look and see.
Check if your system path environmental variable includes the PHP installation directory. That worked for me on with PHP 7.1 / Apache 2.4 / Windows Server 2016.
So basically i am trying to run yii-framework on wamp server but required higher version of php (5.4 above). In my Wamp server, the php version is 5.5 which i have checked on browser (localhost). But the when i run it on windows, it fails because the windows version is only 5.3. It causes the yii framework fail too because when i type php requirements.php. it does not work.
There is no Windows version of PHP so basically you must have installed a version of PHP manually i.e. not with WAMPServer.
This will probably have added an entry on you PATH ( always a bad idea when using WAMPServer anyway as you can have many versions of PHP on your system at one time with WAMPServer)
Look at your PATH and if you must, amend it to point to the PHP in \wamp\bin\php\php{version}
A better way is to remove any reference to PHP from the PATH environmant variable and write a simple batch file to add php to your path only when you want to, like this
Batch file saved in C:\windows\phppath.cmd
echo off
PATH=%PATH%;c:\wamp\bin\php\php5.4.16
Assuming you have php5.4.16 on your wampserver install.
I am working on an older project that uses functions not supported by the newer PHP version included in my version of XAMPP.
I want to temporarily change to an older version of PHP, so I'm looking for a way to switch between PHP versions in XAMPP.
Unfortunately, refactoring to use the newer version of PHP is not an option.
I would not dare to 'temporarily' shift my development machine.
I would suggest installing a virtual machine manager like VirtualBox and then install a older version of XAMPP in there.
I am really disappointed with the responses on this.
WAMP allows you to switch between PHP and MySQL versions pretty easily...
I did following steps on Windows:
Download your XAMPP with your desired PHP version (the VC-11.zip version)
Unzip on C:/xamppXXXX/ (XXXX -> Your PHP version, for example), so you'll have both C:/xampp/ (your first installed version) and the new.
3a. Find in all .conf, .ini, .bat files from the xamppXXXX folder /xampp/ and replace for C:/xamppXXXX/. You can use any IDE like SublimeText to find the string.
3b. Find in all .conf files from the xamppXXXX folder \xampp\ and replace for \xamppXXXX\
You can start MySQL from your installed version control panel and open the C:/xamppXXXX/xampp-control.exe and launch Apache from this one.
I did this with php7 installed and php5 from zip and working fine. Opening different instances of XAMPP Control Panel is the best way to have all databases together and not losing them between versions.
Dont' use XAMPP for this. Use MAMP. It's a single click
I am trying to debug this simplepie.inc (called from index.php )which is dumping me with error during parsing one of the feed.
After stepping through the line $utf8_data = 'UTF-8'; which I hardcoded in to test things out, the value of the variable remains <Uninitialized> as shown in the screenshot below.
Why is that so?
Variables and values are showing up nicely if I am stepping through the debug in index.php thou.
alt text http://a.imageshack.us/img713/486/14jul10105825pm.jpg
There is an existing bug in the 2.0.x branch of XDebug with PHP 5.3 which prevents local variables from being visible. I would recommend updating/building either the latest version from SVN, or using a recent 2.1.x release, even if in RC/Beta status.
More information available here: http://www.eclipse.org/forums/index.php?t=tree&th=158396
This issue has bugged me for almost a year. Actually we had to set up virtual machines with ubuntu because we did not get xdebug to work on windows.
I just downloaded XAMPP 1.7.7 from www.apachefriends.org and it seams that this bug has been fixed now.
ActiveState provides precompiled versions of Xdebug for most operating systems. Package can be downloaded from this page;
http://code.activestate.com/komodo/remotedebugging/
Look for "PHP Remote Debugging Client" and download for your OS.
If you choose this option, take the xdebug.so from the appropriate PHP version directory and use it.
If you're updating a XAMMP for Mac install, it's in the XAMMP folder.
xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/xdebug.so
Snagged from here:
http://kubyshkin.ru/posts/installing-php-xdebug-extension-on-mac-os-x-10-7-lion.html