PHP requirement error when installing spatie-media-library-pro

710 Views Asked by At

I'm trying to install spatie/laravel-medialibrary-pro:^2.0.0 but hitting the error "- spatie/laravel-medialibrary-pro 2.0.0 requires php ^8.0 which does not match your installed version 7.4.14."

My IDE is phpstorm which is using PHP 8.1. My composer.json requires php 8.1

I think I can work around the problem by using "composer install --ignore-platform-reqs" but I'd prefer to understand why I'm hitting the problem. All thoughts are appreciated!

1

There are 1 best solutions below

0
On

It probably depends on your development environment.

Laravel Homestead

If you're using Laravel Homestead, you can change PHP version in different ways:

  1. Running php81. This will change the default CLI version for all applications installed in the Virtual Machine
  2. Adding the version to Homestead.yml
    sites:
    - map: your-site.test
      to: /home/vagrant/your-site/public
      php: "8.1"
    

Laravel Sail

If you're using Laravel Sail, you should update the build definition of the your-site.test container in your application's docker-compose.yml file:

# PHP 8.1
context: ./vendor/laravel/sail/runtimes/8.1

Custom setup

In any other case, it will depend on how your local env is setup. Try running php -v to figure out what version the CLI is using.