stackauth stackauth
stackauth stackauth

Reputation: 89

Composer requires php version 7 ->

I have uploaded my laravel project on a subdomain which requires php 7 and above. I have updated the subdomain to use php 7. However when run the composer install, it says my php version is 5.6, which is the global version. In the project, i check the version php -v and it shows the version as php v7.

How come the composer is running with php version 5.6 ? Please help

Upvotes: 1

Views: 862

Answers (3)

Udochukwu Enwerem
Udochukwu Enwerem

Reputation: 2823

Let Composer know the version of PHP you are using in your Laravel app by including a platform key in the config section of your composer.json file and reinstalling composer.

For instance, if you have the version of php7 as 7.1.3, you can update composer.json like this:

{ 
    "name": ".../...", 
    "config": { 
        "platform": { 
            "php": "7.1.3" 
        } 
    }, 
    "require": {
        ... 
    } 
}

Note: The the PHP version you provide with the platform key is the version of php for the environment where your app is installed, while the version you provide with the require key is the minimum php requirement for your application.

Upvotes: 0

freeek
freeek

Reputation: 978

As and alternative you can also use docker image of composer:

docker run --rm --interactive --tty \
  --volume $PWD:/app \
  composer install

Upvotes: 0

Luca C.
Luca C.

Reputation: 12564

you can skip platform check with this:

composer install --ignore-platform-reqs

otherwise you can run:

php composer.phar install

to use the php exetutable that you prefer

Upvotes: 2

Related Questions