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.
Related
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 (...)
I just moved my Laravel application to production server. I am trying to execute artisan command via PuTTy which ends with
[Error Exception] Invalid argument supplied for foreach()
What I've tried
Reading about the topic, forum suggested few things
1) Setting file permission for storage directory to 0755
2) Tried executing artisan command using php-cli. At bluehost I can access
php-cli at /ramdisk/php/54/bin/php54-cli
Command
/ramdisk/php/54/bin/php54-cli artisan list
Result
Commands ends up showing nothing.
Any pointers towards issue are highly appreciated.
Laravel 5.2 is not compatible with PHP 5.4, it seems you are using it.
You may consider to update your PHP version to PHP >= 5.5.9 (or, worst solution, downgrade Laravel). It can not work with this version.
Anyway, if you want to understand error, you could have a look at your logs (in storage/logs/), but maybe it's empty, due to the incompatibility mentioned above.
EDIT
php-cli version must also be >=5.5.9 if you are using laravel 5.2. Make sure you point out to the right php file
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 trying to setup Symfony2 with PHPStorm 7.1.3 using these instructions but I am running into an error when i execute php app/console server:run.
The error I see is
[InvalidArgumentException]
There are no commands defined in the "server" namespace.
This is what my development machine has
WAMP: 2.5
PHP : 5.5.12
OS : Windows 7
So after getting this error I went to google to do some search and saw many people who had similar problem were using PHP 5.3 and the command line was built for PHP5.4 on wards. I then installed a new version of WAMP which came with PHP 5.5.12 assuming and hoping the error to go away and let me move on to development but then I got the same error again. Now something tells me may be I did not configure something right so I went to see the PHP settings and all seems fine to me.
I am not sure what else to do to get it to work, I will really appreciate if anyone can guide me in setting up Symfony2 with PHPStorm.
UPDATE:
I ran a command php -v to double the php version and it says PHP 5.3.13
You are clearly using Terminal and not Command Line Tools (CLT). The manual you are referring to was made for older version where terminal was not yet available and it refers to CLT (which you are NOT using).
Since you are using Terminal, make sure that your system-wide PHP is actually v5.5. You can verify this by executing php -v command.
Terminal and "Command Line Tool Support" plugin are two different things. First is the same as your real console/terminal (e.g. cmd.exe on Windows) .. while second is some custom emulator (don't know better word/term) which can use PHP Interpreter from PhpStorm settings if configured accordingly (as per manual).
If you want to use Command Line Tools:
It is located at Tools | Run Command... .
Make sure that you have created php alias (as per that manual) so it refers to currently select PHP Interpreter from IDE settings. Otherwise php command may fail. Aliases can be configured at Settings | Command Line Tool Support.
If you want to use Terminal:
You have 2 choices here:
Use FULL path to correct php.exe instead of just php
Make php v5.5 default system-wide. For this you have to:
Alter your PATH environment variable (My Computer | Right click | Properties | Advanced System Settings | Advanced | Environment variables...) and place folder where correct PHP 5.5 is located in front of the list
Restart IDE (most likely will be required) so it picks up these changes to environment variables.
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.