Change php cli version - php

php -v
PHP 7.0.10-2+deb.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.10-2+deb.sury.org~xenial+1, Copyright (c) 1999-2016, by Zend Technologies
I use 5.6 with magento so I get errors. How can i change this? It must be 5.6?
i did this but did not work
sudo apt-add-repository ppa:ondrej/php5

You can set alias in your bash profile.
For Ubuntu edit: ~/.profile
For Centos edit: ~/.bash_profile
You can add alias before the export path command like
alias php='/opt/rh/rh-php56/root/usr/bin/php'
After saving execute by typing '. ~/.profile' (or '. ~/.bash_profile') and your version is now set until you close your terminal.

Related

PhpStorm: Run PHP server doesn't work: could not find driver

I am using PhpStorm for a year and now I want to run my PHP server using the PHP Run menu:
I run the server pushing the green arrow button. Then the console show:
/home/john/.cache/JetBrains/PhpStorm2020.1/plugins/idea-php-latest-plugin/php-v7.3.1/php.sh -S localhost:8080 -t /home/john/my-nice-project/backend/web
Then I go to localhost:8080 in my browser and I see this error:
I execute php -v in my terminal and I can see this:
PHP 7.2.34-18+0~20210223.60+debian10~1.gbpb21322 (cli) (built: Feb 23 2021 16:47:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.34-18+0~20210223.60+debian10~1.gbpb21322, Copyright (c) 1999-2018, by Zend Technologies
So maybe the problem is the version of the PHP interpreter: I have 7.2.34 and PhpStorm has php-v7.3.1 configure.
Is there any way to configure the version?
But if I execute this command, it works fine:
php yii serve --docroot="backend/web/"
Add this to your php.ini file:
extension=pdo.so
https://www.php.net/manual/en/pdo.installation.php

php -v shows PHP 7.2.24

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

php versions are shown differently in WHM and server

In server, it shows 7.0 php like below from either cPanel
or cat /etc/apache2/conf.d/php.version in server
However in php --version, it shows php5.6.
How can I upgrade my php to 7.0? Thanks.
If you change PHP version from cpanel account it will be applied and your website will use the new version.
php -v command shows the default version of PHP for your system but if you want to check PHP version for your cpanel account only you have to modify your ~/.bashrc file:
alias php="/opt/cpanel/ea-php70/root/usr/bin/php"
and then:
source ~/.bashrc
Now you'll find the output some thing like:
php -v
PHP 7.0.33 (cli) (built: xxxxxx) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies

Don't work composer in PHP 7.0

Don't work composer in PHP 7.0
I insert this command to the terminal:
$sudo composer require cocur/slugify
In the directory is created only one empty file composer.json
My OS:
Ubuntu 14.04
My PHP:
PHP 7.0.1-5+deb.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
with Xdebug v2.4.0RC2, Copyright (c) 2002-2015, by Derick Rethans
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
Sorry, the application php7.0 has stopped unexpectedly
php7.0 crashed with sigsegv in xdebug_var_export
To get rid of the error, you might simply disable the Zend Extension "xdebug" for Composer runs:
;zend_extension = "/path/to/xdebug.so" in php.ini.

ln: /usr/bin/php: Operation not permitted OSX 10.11

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 ...

Categories