MAMP vs system PHP .. completely separate? - php

How does the PHP that MAMP uses run differently from the PHP installed on my Mac?
For example, if if place an bare "phpinfo()" file and access it through my browser into MAMP/htdocs .. the information supplied is my MAMP PHP setup, correct?
But if I terminal into that same folder and "php -i" from command line, I will get the details of my Mac's "system" PHP, correct?
So does that mean that extensions must be separately installed into both setups? Do they need to be managed as 2 completely separate entities? Any PEAR packages installed via command line will not be available to MAMP? If I want to keep the two synchronous I must "double" everything?

All user-installed versions of PHP are installed into a separate folder, keeping the original install of PHP intact. MAMP is only set up to use its version of PHP in the browser.
You can change this behavior by updating your PATH to use MAMP's version, if you don't care about the stock PHP version (which is fairly old). You can do that by adding the following line to your ~/.bash_profile (don't forget to double-check the exact path, so you get it right):
export PATH=/Applications/MAMP/bin/php5/bin/:$PATH
This will make all references to PHP use MAMP's version.
If you need to use the stock version of PHP for whatever reason and don't want to do the above, then you can create an alias. More details for creating command line aliases can be found in this related SO post.

Related

How can I use a specific PHP version when running a powershell command/instance without changing the global version?

I am trying to run a seed command for an application but windows power shell runs it with PHP 5, when the app is running on PHP 7. I need it to run that one command assuming php as version 7, that is, without changing the version of PHP powershell is using permanently.
I have tried all the solutions I've managed to find online, but unfortunately the majority of them are targeted to Linux systems, not windows.
This includes:
editing composer.json/lock;
defining an alias of php pointing to the path of the version 7 and using it to run the command;
altering the PHP version using PHP manager in IIS
Among others.
Is this a possible thing to do? No matter what I do, my seed command always assumes php5 as the one to use, which results in several "syntax" errors namely complaining about the double question mark "??" null syntax only introduced in PHP 7.
First of all you must have php 7 installed.
Then in windows:
Go to Control Panel and open the System icon (Start → Control Panel)
Go to the Advanced tab
Click on the 'Environment Variables' button
Look into the 'System Variables' pane
Find the Path entry (you may need to scroll to find it)
Double click on the Path entry
replace your PHP 5 directory path with php 7 path)
Press OK
Open terminal again and try again.
You could use different version of PHP in IIS side by side.
IIS support to specify different version PHP-CGI.exe for each sub-application or folder by following steps.
https://learn.microsoft.com/en-us/iis/application-frameworks/install-and-configure-php-applications-on-iis/using-fastcgi-to-host-php-applications-on-iis
You could map PHP5 as global Version and create a sub-application to handle the specific Powershell script, then set module mapping to PHP 7 for this sub-application's handler.
So that the specific page with PHP 7 will not interfere global application.
The way I solved it was by adding in my script files "set PATH=C:\Program Files\PHP\v7.0" before the instructions.
Also needed to add in my environment variables the parameters to accept CMD commands in Powershell.
This was my script file:
set PATH=C:\Program Files\PHP\v7.0
cmd "/C php artisan (...)

VSCode - php not installed?

I have VSCode installed, but don't seem to have php - i.e. there is no "php.exe" anywhere on my computer. No guides that I can find on the web about setting VSCode up for PHP suggests that I need to download and install php itself seperately (only debuggers and linters)... my question is:
Do I need to install PHP seperately? Should I have had to do this, or is there a bug in my VSCode installation...
Yes you need to install PHP from the php website and then tell VSCode where PHP.exe is located.
VSCode is an editor not an interpreter.
I think if you install PHP at the default location VSCode will automaticly pick it up but if not you need to specify its path in options.
If you install XAMPP you will get apache,php and mySql in one installation.
EDIT: an interpreter is software that translated your code(in your case PHP) into code that the CPU can understand and then executes.
#kpollock it' not you. Yes, it should seem obvious that the language should be installed manually or separately, so you should have gotten that part, sorry. But no, there doesn't seem to be information anywhere about defining the underpinnings. This "understanding" seems to be left to the individual through research as you're doing.
After I installed PHP I manually set my environment PATH to include the PHP folder. OR in VS Code you can go to menu>File>Preferences>User Settings, the settings are maintained as a JSON object (unlike VS) and there is a PHP section for the .exe path.
Since you mentioned Node, you may not have installed Node.js manually. (I don't know if Node comes with VS Code either.) It might have come in with a VS2015 extension like Gulp or some other higher-level functionality, or maybe it was an installation option with VSC. If you can't use node or npm from a console, set your environment PATH to include it.

composer on system with differents php installation Cpanel

I need use composer for a project on any servers.
This server has a very old PHP version on system.
But i don't need to use Cpanel PHP version.
I need for my own program use Cpanel internal version locate at /usr/local/cpanel/3rdparty/php/54/
I try modify shebang
Original
#!/usr/bin/env php
Changed
#!/usr/local/cpanel/3rdparty/php/54/
But not work.
If /usr/local/cpanel/3rdparty/php/54/ includes a php binary you have to give that path to shebang:
#!/usr/local/cpanel/3rdparty/php/54/php
Also you should be able to call /usr/local/cpanel/3rdparty/php/54/php composer.phar.

PHP version - Command line vs Web browser

Using phpinfo() in my browser, I see that my PHP version is 5.4.21. However, using "php -v" at a command line prompt, my PHP version reads 4.4.9. I'm not the original PHP installer on this server, so I'm not sure why the mismatch. However, I need the command line version to match (or at least, be close) to my browser version.
Is there a way I can update my command line PHP only? If so, can someone point me to a solution?
I've found similar posts here on SO but none with my particular question and needed solution:
different version php on command line and in apache
PHP Command Line & Browser Returning Different Results
Use 'where php' (windows) or 'which php -a' (rest of the world) to get the location of the php-binary you are using with the commandline. If the 5.X version shows up as secondary entry, one may consider deleting 4.x (after making sure, you have a backup around and ini-files are not shared between both versions). If it does not, modify your PATH to include the 5.5 location prior to the 4.X version (or delete/upgrade later)
This implies that you use php direclty without specifing a location.
If one of the versions is installed using the packet-manager of your choice, go check out their documentation before performing any steps.

install php on server (iis6) when php already exists due to backup exec

I need to install or use php on a windows 2003 server that already has php 5.2.0.0 installed due (I think) to setting up symantec backup exec. I don't want to interfere with backup exec's php.ini settings - and would rather be able to control my own configuration of php.
searching for php shows that php.exe and other php files are currently installed in
c:\program files\symantec\backup exec\
I'm almost certain that installing the current version of php 5.2.8 to c:\php would be disastrous or calamitous in some way.
There is no PHPRC entry in the server properties > environment variables and I'm pretty sure that the php.exe location is not included in the PATH variable. ...unless the actuall install location is different from the c:\program files\symantec\backup exec\ dir.
Any suggestions on how to proceed?
I'm almost certain that installing the current version of php 5.2.8 to c:\php would be disastrous or calamitous in some way.
What makes you say that :) I've run separate PHP versions on the same machine side by side and not run into bother.
AFAIK the Symantec install should not conflict with your own installation, nor should the separate php.ini files conflict with each other.
[Response to comment]
First thing to note is that I have no experience of Backup Exec or what it uses PHP for. I'm guessing it uses it for its own internal stuff and doesn't spread itself over the OS. Test this by searching for php.ini and php DLLs on the file system. I'm betting it's all quite self contained. PHP searches for the config file as noted here: PHP Site . As you note, BE hasn't set the PHPRC variable. Check it hasn't used those Registry entries either. On a different tack, has BE installed an admin site already on IIS? If so, check the IIS Web Service Extensions to make sure it hasn't already registered the PHP ISAPI dll or PHP CGI exe. IF not, I think you should be okay for your new install.
To be on the safe side, do a manual PHP install as illustrated here: PHP Site. That way, you know exactly what you have installed, and can easily remove the files again if they cause a problem. I can't imagine a problem here that would require you to reinstall BE.

Categories