5

im having issues to install laravel under my server running php 5.3 by default BUT i'm able to pick a version of php to run under any specific directory.

guzzlehttp/guzzle 4.1.2 requires php >=5.4.0 -> your PHP version does not satisfy that requirement.

so i choose php 5.4 to run on the directory that im trying to install laravel, but composer do not know that im running PHP 5.4 in that directory.

How to fix this problem?

7
  • Composer is using the php settings that invoke it, in this case likely the CLI setting generally found in /etc/php/cli/php.ini. Inorder for you to get around that error you will need to have your CLI php version higher Commented Apr 28, 2015 at 0:08
  • how to do that would be very helpful. Commented Apr 28, 2015 at 0:56
  • what OS are you running on? Commented Apr 28, 2015 at 0:56
  • Its on linux, probably CENTOS OS Commented Apr 28, 2015 at 0:58
  • Or better yet if you know the full path the the php5.4 install dir then just do /full/path/to/php5.4/php composer.phar install from inside the project directory Commented Apr 28, 2015 at 0:58

3 Answers 3

15

Try running composer command with --ignore-platform-reqs, e.g.

composer install --ignore-platform-reqs
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks best solution to bypass php version requirements. This solution works great for another project where installing using composer requires v7.1. I have all version of php but don't want to change system env. variable.
This is the correct answer. Please award the answerer with your approval
Thank you, using composer update --ignore-platform-reqs worked for me.
you can use composer install --ignore-platform-reqs command if you use different php version and composer required version
2

When you execute composer install/update it runs with your default PHP version of your machine. To make it work with specific versions (that's example path on my Mac) please change it with your executable php path.

/usr/local/Cellar/php71/7.1.8_20/bin/php composer.phar install

Comments

1

This might help some... composer is likely to be using /usr/bin/php, consider the following:-

$ which php
/usr/bin/php

$ /usr/bin/php -v
PHP 7.1.33

$ php -v
PHP 7.2.24

$ type -a php
php is aliased to '/usr/bin/php7.2'
php is /usr/bin/php

$ which composer
/usr/local/bin/composer

As you can see our hosting has an alias to ensure the configured version of php (for webserver) is used on command line. But composer is configured to use /usr/bin/php.

The following is a workaround for the above circumstance.

Update .bash_aliases file

alias php="/usr/bin/php7.2"
alias composer="/usr/bin/php7.2 /usr/local/bin/composer"

Once logged out of terminal and logged back in...

$ type -a composer
composer is aliased to '/usr/bin/php7.2 /usr/local/bin/composer'
composer is /usr/local/bin/composer

composer is now using the correct php version.

1 Comment

Hello, where can I find .bash_aliases file? Im on Laravel 8.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.