I just wondering how composer check which php to use when check for requirements. I use MacOS and in terminal type:
composer require phpunit/phpunit
the result is something like:
Problem 1
- phpunit/phpunit 5.0.4 requires php >=5.6 -> your PHP version (5.5.27) or "config.platform.php" value does not satisfy that requirement....
When I check php version:
php -v
The result is:
PHP 5.6.10 (cli) (built: Jun 12 2015 14:08:56) Copyright (c) 1997-2015
The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend
Technologies
with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
Which is:
which php
php: aliased to /Applications/MAMP/bin/php/php5.6.10/bin/php
Can someone explain this. Thanks in advance!
Composer can tell you what version of PHP it's running on, if you specify debug verbosity -vvv.
I like to run it with the about command, since the output is relatively short.
composer -vvv about
Example output:
...
Running 1.8.5 (2019-04-09 17:46:47) with PHP 7.3.5 on Darwin / 18.6.0
...
Edit:
This has gotten more interest than I expected, so here's a version with cleaner output:
composer -vvv about 2>&1 | grep "PHP"
On MacOs X the default installation of php resides in /usr/bin. If you upgrade your php it will most likely be installed somewhere else (like /usr/local/php5), or if you use MAMP or something else it will be elsewhere. Just make sure that the first occurrence of php when traversing your PATH is the same as the version your webserver is using. (like have /usr/local/php5/bin before /usr/bin in your PATH). That will solve your problem.
If you used a package install method, such as apt-get on Ubuntu, chances are that the executable will include a "shebang" pointing to the specific php that should be used to run that specific composer file.
When using the command composer the cli will first resolve which binary to use. By running which composer you can find what binary that is.
$ which composer
/usr/bin/composer
Once you know that, you can open the file, for instance using vim: vim /usr/bin/composer (generally it takes super user access to modify binaries so you shouldn't be able to mess composer up doing that).
On the first line of the composer binary should be a shebang, possibly looking like #!/usr/bin/php that would instruct the composer executable on how it should run.
You can then call that php binary directly to verify its version:
/usr/bin/php -v
( sharing this here because I was looking for it an landed here but nothing satisfied me so I will share for those who land here for the same reason: )
With the following command you can check which composer packages depend on a specific php version:
composer depends php | grep 8.1
will output something like:
symfony/console v6.1.4 requires php (>=8.1)
symfony/css-selector v6.1.3 requires php (>=8.1)
symfony/deprecation-contracts v3.1.1 requires php (>=8.1)
symfony/error-handler v6.1.3 requires php (>=8.1)
symfony/event-dispatcher v6.1.0 requires php (>=8.1)
symfony/event-dispatcher-contracts v3.1.1 requires php (>=8.1)
symfony/finder v6.1.3 requires php (>=8.1)
symfony/http-foundation v6.1.4 requires php (>=8.1)
symfony/http-kernel v6.1.4 requires php (>=8.1)
symfony/mailer v6.1.4 requires php (>=8.1)
symfony/mime v6.1.4 requires php (>=8.1)
symfony/process v6.1.3 requires php (>=8.1)
symfony/routing v6.1.3 requires php (>=8.1)
symfony/service-contracts v3.1.1 requires php (>=8.1)
symfony/string v6.1.4 requires php (>=8.1)
symfony/translation v6.1.4 requires php (>=8.1)
symfony/translation-contracts v3.1.1 requires php (>=8.1)
symfony/var-dumper v6.1.3 requires php (>=8.1)
Related
I have a problem with a Symfony project that I have to work on, when I try a 'composer install' on my bash, I have this message :
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for ocramius/package-versions 1.5.1 -> satisfiable by ocramius/package-versions[1.5.1].
- ocramius/package-versions 1.5.1 requires php ^7.3.0 -> your PHP version (7.2.24) does not satisfy that requirement.
Problem 2
- ocramius/package-versions 1.5.1 requires php ^7.3.0 -> your PHP version (7.2.24) does not satisfy that requirement.
- ocramius/proxy-manager 2.2.3 requires ocramius/package-versions ^1.1.3 -> satisfiable by ocramius/package-versions[1.5.1].
- Installation request for ocramius/proxy-manager 2.2.3 -> satisfiable by ocramius/proxy-manager[2.2.3].
It seems obvious that my php version isn't up-to-date and I have to upgrade to the 7.3.0 version minimum, but when I make an 'apt search php', the latest version that I have is 7.2 and the 'php -v' command return this message :
PHP 7.2.24-0ubuntu0.18.04.3 (cli) (built: Feb 11 2020 15:55:52) ( 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.3, Copyright (c) 1999-2018, by Zend Technologies
Did anyone how can I force the upgrade of my php version ? It will be very helpfull.
Thanks & have a great day
You can upgrade your PHP version, depending of your OS but you can also "fix" the PHP version in your project with composer.json. In your composer.json you may have a "config" key, add "platform" with your PHP version, 7.2 in your case:
{
"name": "xxxx",
...
"config": {
"platform": {
"php": "7.3"
}
},
...
}
It's recommended to fix the version that you have in production :
Official doc: https://getcomposer.org/doc/06-config.md#platform
Check also this blog article : https://blog.martinhujer.cz/17-tips-for-using-composer-efficiently/ (Tip #15)
To update PHP version to 7.3 on linux, here is steps :
sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt -y install php7.3
If you need to install additional packages:
sudo apt-get install -y php7.3-{bcmath,bz2,intl,gd,mbstring,mysql,zip}
I am updating the composer and it shows up some error like below.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- pusher/pusher-php-server v3.4.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- pusher/pusher-php-server v3.4.0 requires php >=5.4 <7.3 -> your PHP version (7.3.6) does not satisfy that requirement.
- pusher/pusher-php-server v3.3.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- pusher/pusher-php-server v3.3.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- pusher/pusher-php-server 3.4.x-dev requires ext-curl * -> the requested PHP extension curl is missing from your system.
- Installation request for pusher/pusher-php-server ^3.3 -> satisfiable by pusher/pusher-php-server[3.4.x-dev, v3.3.0, v3.3.1, v3.4.0, v3.4.1].
To enable extensions, verify that they are enabled in your .ini files:
- C:\PHP7\php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
the pusher v3 doesn't support php version that higher than 7.3
there are some options :
first is downgrade the php to the requirement (not recomended), the second one is use this command to upgrade the pusher to version 4
composer require pusher/pusher-php-server
could please check curl enabled in your php use ;extension=php_curl.dll remove semi colon in php.ini file and try
try following command
install first curl using following command.
sudo apt-get install curl
then use
sudo apt-get install composer
While trying to use Composer to create a Symfony 4 project I got the following error:
steve#laptop ~ $ php composer.phar create-project symfony/skeleton my-proj
Installing symfony/skeleton (v4.0.0)
- Installing symfony/skeleton (v4.0.0): Loading from cache
Created project in my-proj
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- symfony/framework-bundle v4.0.1 requires ext-xml * -> the requested PHP extension xml is missing from your system.
- symfony/framework-bundle v4.0.0 requires ext-xml * -> the requested PHP extension xml is missing from your system.
- Installation request for symfony/framework-bundle ^4.0 -> satisfiable by symfony/framework-bundle[v4.0.0, v4.0.1].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.2/cli/php.ini
- /etc/php/7.2/cli/conf.d/10-opcache.ini
- /etc/php/7.2/cli/conf.d/10-pdo.ini
- /etc/php/7.2/cli/conf.d/20-calendar.ini
- /etc/php/7.2/cli/conf.d/20-ctype.ini
- /etc/php/7.2/cli/conf.d/20-exif.ini
- /etc/php/7.2/cli/conf.d/20-fileinfo.ini
- /etc/php/7.2/cli/conf.d/20-ftp.ini
- /etc/php/7.2/cli/conf.d/20-gettext.ini
- /etc/php/7.2/cli/conf.d/20-iconv.ini
- /etc/php/7.2/cli/conf.d/20-json.ini
- /etc/php/7.2/cli/conf.d/20-phar.ini
- /etc/php/7.2/cli/conf.d/20-posix.ini
- /etc/php/7.2/cli/conf.d/20-readline.ini
- /etc/php/7.2/cli/conf.d/20-shmop.ini
- /etc/php/7.2/cli/conf.d/20-sockets.ini
- /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.2/cli/conf.d/20-sysvsem.ini
- /etc/php/7.2/cli/conf.d/20-sysvshm.ini
- /etc/php/7.2/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
steve#laptop ~ $ php --ini
steve#laptop ~ $ php --version
PHP 7.2.0-2+ubuntu16.04.1+deb.sury.org+2 (cli) (built: Dec 7 2017 20:14:31) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.2.0-2+ubuntu16.04.1+deb.sury.org+2, Copyright (c) 1999-2017, by Zend Technologies
steve#laptop ~ $ sudo apt-get install php-xml
[sudo] password for steve:
Reading package lists... Done
Building dependency tree
Reading state information... Done
php-xml is already the newest version (1:7.1+55+ubuntu16.04.1+deb.sury.org+1).
0 to upgrade, 0 to newly install, 0 to remove and 253 not to upgrade.
I did search in php.ini for ext-xml to see if I could uncomment it in order to enable it but I did not find any mention of ext-xml. I have not searched anywhere else because I am very unsure about what I am doing.
Any help would be very much appreciated, Steve
It looks like you're using ubuntu 16.04 with the ondrej/php ppa to get the latest version of php. In this case, the package names need to match the version of php you're using:
apt-get install php7.2-xml
You can see the different versions available with something like this:
apt-cache search php | grep xml
Depending on your configuration, you may need to prefix the installation command with sudo.
Try out
Step 1:
sudo apt install php-xml
Step 2:
Restart apache
Resolved my issue
On Amazon linux or Centos
sudo yum install php-xml
if you're running on nginx restarting is not needed
Remove all versions for php and install only one version
I recently downgraded my PHP-FPM version from 7 to 5.6 by purging nginx and php-fpm and removing the php 7 fpm folder. It went well as my php version is now 5.6.
$ php -v
PHP 5.6.30 (cli) (built: Dec 13 2017 00:40:36)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
My problem is whenever I do a composer install on my project, I get the following errors:
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for behat/behat 3.2.x-dev -> satisfiable by behat/behat[3.2.x-dev].
- behat/behat 3.2.x-dev requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
Problem 2
- Installation request for behat/behat dev-master -> satisfiable by behat/behat[dev-master].
- behat/behat dev-master requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
Problem 3
- Installation request for instaclick/php-webdriver 1.4.5 -> satisfiable by instaclick/php-webdriver[1.4.5].
- instaclick/php-webdriver 1.4.5 requires ext-curl * -> the requested PHP extension curl is missing from your system.
Problem 4
- behat/behat 3.2.x-dev requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- behat/symfony2-extension dev-master requires behat/behat ~3.0,>=3.0.4 -> satisfiable by behat/behat[3.2.x-dev].
- Installation request for behat/symfony2-extension dev-master -> satisfiable by behat/symfony2-extension[dev-master].
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/7.1/cli/php.ini
- /etc/php/7.1/cli/conf.d/10-opcache.ini
- /etc/php/7.1/cli/conf.d/10-pdo.ini
- /etc/php/7.1/cli/conf.d/15-xml.ini
- /etc/php/7.1/cli/conf.d/20-calendar.ini
- /etc/php/7.1/cli/conf.d/20-ctype.ini
- /etc/php/7.1/cli/conf.d/20-dom.ini
- /etc/php/7.1/cli/conf.d/20-exif.ini
- /etc/php/7.1/cli/conf.d/20-fileinfo.ini
- /etc/php/7.1/cli/conf.d/20-ftp.ini
- /etc/php/7.1/cli/conf.d/20-gettext.ini
- /etc/php/7.1/cli/conf.d/20-iconv.ini
- /etc/php/7.1/cli/conf.d/20-json.ini
- /etc/php/7.1/cli/conf.d/20-phar.ini
- /etc/php/7.1/cli/conf.d/20-posix.ini
- /etc/php/7.1/cli/conf.d/20-readline.ini
- /etc/php/7.1/cli/conf.d/20-shmop.ini
- /etc/php/7.1/cli/conf.d/20-simplexml.ini
- /etc/php/7.1/cli/conf.d/20-sockets.ini
- /etc/php/7.1/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.1/cli/conf.d/20-sysvsem.ini
- /etc/php/7.1/cli/conf.d/20-sysvshm.ini
- /etc/php/7.1/cli/conf.d/20-tokenizer.ini
- /etc/php/7.1/cli/conf.d/20-wddx.ini
- /etc/php/7.1/cli/conf.d/20-xmlreader.ini
- /etc/php/7.1/cli/conf.d/20-xmlwriter.ini
- /etc/php/7.1/cli/conf.d/20-xsl.ini
As you can see the errors still reference PHP 7 which is really odd considering my PHP version is now 5.6.
Any ideas what might be wrong? Thank you.
move (or remove) your lock file to a tempory name and do a composer update again . This will get rid of old data contained in your lock file and only use the most up to date data from your composer.json
mv composer.lock{,.bak} #move to composer.lock.bak
composer install #installs the project dependencies from the composer.lock file if present, or falls back on the composer.json
As an unrelated note, to make sure you are using the correct php version for your web server, create a web page in your website's root folder containing only :
<?php phpinfo();
as php -v only gives the version of the command line version.
This is my error, I found it on google, and I don't know where is the error. I have MAMP PRO with php 5.4.4 version
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework v4.2.4 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.3 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.2 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.1 requires php >=5.4.0 -> no matching package found.
- laravel/framework v4.2.0 requires php >=5.4.0 -> no matching package found.
- Installation request for laravel/framework 4.2.* -> satisfiable by laravel/framework[v4.2.0, v4.2.1, v4.2.2, v4.2.3, v4.2.4].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.
Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
OS X is pre-installed with its own PHP, and it's probably older than 5.4 that Laravel 4.2 requires. And when you do php in your terminal, you'll probably get your OSX's php. Try it with php -v
You'll need to make your MAMP PRO's php your default binary, as suggested in change the PHP path to MAMPs PHP Try:
export PATH=/Applications/MAMPPRO/php5.4.4/bin:$PATH
This will only work up until you close your terminal. To make the change permanent, add the line above to your ~/.bash_profile
Then you check again by typing which php to your terminal. It should now point to your MAMP PRO's PHP binary.
Use homestead , its a vagrant box that will help your development.
https://github.com/laravel/homestead
You can set up a virtualbox with debian.
virtualbox: https://www.virtualbox.org
debian: https://www.debian.org
web server install tut:
http://www.howtoforge.com/ubuntu-lamp-server-with-apache2-php5-mysql-on-14.04-lts
or install homestead: http://laravel.com/docs/homestead
And read this: https://www.andrewmunsell.com/blog/development-environments-with-vagrant-and-puppet
Alternatively, if you are comfortable with the terminal, installing Apache & PHP, you can use MacPorts to install any version of PHP >= 5.4.
MacPorts