On Ubuntu machine:
$ php -v
PHP 5.5.10-1~dotdeb.1 (cli) (built: Mar 6 2014 18:55:59)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with uopz v2.0.4, Copyright (c) 2014, by Joe Watkins <krakjoe#php.net>
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
My test.php file is simple:
<?php
exit(1);
I would expect this command php test.php || echo "error" to show "error" but it exits with status code 0.
$ php test.php
$ echo $?
0
But on the same machine the same code, but not in file works as expected:
$ php -r "exit(1);" || echo "error"
error
or
$ php -r "exit(1);"
$ echo $?
1
On different machine (archlinux) with php:
PHP 5.5.13 (cli) (built: May 29 2014 05:46:58)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
All cases work as expected, even when the code is run from file the status code is 1.
This is a true problem because git hooks depends on this status codes and Jenkins and I couldn't google it out.
Could it be somehow config-related? I checked cli php.ini and couldn't find anything suspicious.
The uopz extension is the problem. It "corrupts" the exit code. There was a bug opened about this issue.
You can try to set the configuration uopz.overloads=0 as it was recommended in the bug comments. That, unfortunately didn't work for me. Only disabling the extension fixed the issue.
Related
I downloaded & installed xampp-linux-x64-7.4.6-0-installer.run on my VM using terminal. Everything went right except PHP version.
The terminal output
php -v
PHP 7.2.24-0ubuntu0.18.04.4 (cli) (built: Apr 8 2020 15:45:57) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.4, Copyright (c) 1999-2018, by Zend Technologies
but php info shows version 7.4.6
is there any way to upgrade php version ??
you should be able to use this comand to set the default php version:
sudo update-alternatives --config php
I have an automated process to run a php script on 2 machines. It does the following:
/opt/rh/php54/root/usr/bin/php myphp.php
However, It is not running on Host 1(error: /opt/rh/php54/root/usr/bin/php: not found) but running fine on Host 2:
Host 1: Not running
PHP 7.2.9 (cli) (built: Aug 15 2018 09:19:33) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Host 2: running fine
PHP 5.4.40 (cli) (built: Jul 22 2016 07:31:37)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
/opt/rh/php54/root/usr/bin/php--->>> This path does not exist on host 1
SELinux is disabled on both hosts.
PHP will not be installed to the path u are using. Try to use php myphp.php instead.
The path \opt/rh/php54/root/usr/bin/php does not seem to be correct. Find out the correct path for the php installation directory.
You can use which php or whereis php command.
I'm using Docker composer with a PHP. When trying to set the interpreter I choose Docker compose, I choose the PHP container and then it fails with the error "Failed to parse script validation output".
If I execute php -v inside the container everything seems fine, I tried to set the full path of the PHP executable but I got the same error.
PHPStorm is 2018.2 and php
php -v
PHP 7.1.22 (cli) (built: Sep 15 2018 03:39:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
I use PHPStorm on OSX with PHPUnit and Laravel.
When I go inside my project from the PHPStorm console and type:
$ php --version
PHP 5.5.29 (cli) (built: Sep 9 2015 00:26:40)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
$ which php
/usr/bin/php
From my terminal:
$ php --version
PHP 5.6.16 (cli) (built: Nov 27 2015 21:37:15)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
$ which php
/usr/local/php5/bin/php
The above I installed. I have edited my PATH to use it.
Now I want to change the PHP version inside my PHPStorm.
I tried editing composer.json:
"require": {
"php": ">=5.6.16",
and then running update:
$ composer update
Your requirements could not be resolved to an installable set of packages.
Problem 1
- This package requires php >=5.6.16 but your PHP version (5.5.29) does not satisfy that requirement.
I also tried to create a symbolic link .
$ sudo ln -s /usr/local/php5/bin/php /usr/bin/php
It fails with:
ln: /usr/bin/php: Operation not permitted
I am not sure what to do. I would like to update Php to 5.6.16.
It appears you have at least two versions of Php installed.
Try changing the interpreter path within PhpStorm.
File->settings->languages & frameworks->interpreter ...
I got problem. My PHP 5.5.8 need a few seconds to start.
If in terminal run this command php -v, it will print version only a few seconds later (about 13). But second run prints it immediately. If i wait a little bit all the same.
What to do?
$ time php -v
PHP 5.5.8 (cli) (built: Jan 12 2014 18:50:29)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
real 0m13.375s
user 0m0.029s
sys 0m0.024s