Search code examples
phplaravelversionmamp-pro

Laravel - Cannot install package even though PHP version is the required one


I have a problem with installing some of the composer packages on my project.

Problem 1
    - Installation request for spatie/image-optimizer 1.1.5 -> satisfiable by spatie/image-optimizer[1.1.5].
    - spatie/image-optimizer 1.1.5 requires php ^7.2 -> your PHP version (7.1.14) does not satisfy that requirement.
  Problem 2
    - Installation request for spatie/laravel-feed 2.2.1 -> satisfiable by spatie/laravel-feed[2.2.1].
    - spatie/laravel-feed 2.2.1 requires php ^7.2 -> your PHP version (7.1.14) does not satisfy that requirement.
  Problem 3
    - Installation request for spatie/laravel-newsletter 4.5.0 -> satisfiable by spatie/laravel-newsletter[4.5.0].
    - spatie/laravel-newsletter 4.5.0 requires php ~7.2 -> your PHP version (7.1.14) does not satisfy that requirement.
  Problem 4
    - Installation request for spatie/laravel-referer 1.4.0 -> satisfiable by spatie/laravel-referer[1.4.0].
    - spatie/laravel-referer 1.4.0 requires php ^7.2 -> your PHP version (7.1.14) does not satisfy that requirement.
  Problem 5
    - Installation request for spatie/laravel-sitemap 5.3.0 -> satisfiable by spatie/laravel-sitemap[5.3.0].
    - spatie/laravel-sitemap 5.3.0 requires php ^7.2 -> your PHP version (7.1.14) does not satisfy that requirement.
  Problem 6
    - spatie/image-optimizer 1.1.5 requires php ^7.2 -> your PHP version (7.1.14) does not satisfy that requirement.
    - spatie/image 1.7.2 requires spatie/image-optimizer ^1.0 -> satisfiable by spatie/image-optimizer[1.1.5].
    - Installation request for spatie/image 1.7.2 -> satisfiable by spatie/image[1.7.2].

Even though my PHP version is 7.2.1 these packages are not passing the composer.json validation i.e. cannot be installed. The PHP CLI version is 7.2.1 as well. (checked them all with using the standard procedures phpinfo() and php -v.

I am using MAMP PRO version 4.4.1 and the latest configurable PHP version from the listed versions is 7.2.1 (which is okay since the requirements for these packages ranges from 7.1 to 7.2.

https://github.com/spatie/image-optimizer/blob/master/composer.json#L19

https://github.com/spatie/laravel-newsletter/blob/master/composer.json#L20

https://github.com/spatie/laravel-feed/blob/master/composer.json#L33

https://github.com/spatie/laravel-referer/blob/master/composer.json#L19

https://github.com/spatie/laravel-sitemap/blob/master/composer.json#L19

As I already said the PHP versions are looking good both on the Apache side and CLI side and from the MAMP PRO GUI as well.

PHP 7.2.1 (cli) (built: Jan 15 2018 12:20:50) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies

MAMP PRO config:

MAMP PRO general config 1

MAMP PRO host related config:

MAMP PRO individual config 2

Upgrading PHP to version 7.3 might resolve this issue but I would like to skip that because it has to be done manual without the help of MAMP PRO (since my MAMP PRO version is licensed and I'll need another license to get the built-in PHP versions in it).

Thanks!


Solution

  • Not sure what would cause this except a custom version defined in your composer.json:

    {
        "config": {
            "platform": {
                "php": "7.1.14"
            }
        },
    

    To work around this problem you could tell composer to ignore the version:

    composer require spatie/image-optimizer --ignore-platform-reqs