skip to Main Content

So.. I developed a project with Laravel 9, then I had to upload it to my client’s server by FTP ( which was slow and painful ) to find out only afterwards that my client’s server PHP version could not go over 8.0. I tried to open the project live link ( to where I uploaded ) and the composer platform check was telling me my project had dependencies on PHP 8.1 and that my version is 8.0.

So I tried tweaking the platform check php file to disable this check, to see if it would work anyways but no, the project was throwing errors.

So I decided to downgrade to laravel 8, because after searching around I read that laravel 8 did not need php 8.1.
I guess I read some wrong information because after tweaking my project to downgrade to laravel 8 and uploading again (painfully by ftp), the platform check was again telling me that my project needed PHP 8.1.

So I disabled again this platform check by editing/tweaking the platform check php file, to see if it would work anyway, and it did work. So all good. but then today I was learning how to check which composer packages had dependencies on a specific php version, and in the process I found out (if I’m not wrong) that laravel 8 has package dependencies that depend on PHP 8.1 ?

Is there a table somewhere I can check which Laravel versions depend on which PHP versions or do I have to run some commands on each project to check these dependencies?

Like in the images below:

laravel packages dependent on php 8.1

Thanks !

2

Answers


  1. Short response no, Laravel 8 requires PHP >= 7.3
    From Server Requirements
    But, since you downgraded it is possible that some php packages require newer php versions no matter the version chosen for Laravel.

    Some hints:

    • Change dependencies (packages) version, probably downgrade them.
    • Delete the vendor folder.
    • Delete composer.lock
    • Run composer install

    Checking your screenshot: with symfony the downgrade will not break anything.
    But, check the other package/s ie: tojsverkoyen/css-to-inline-styles requirements.

    Login or Signup to reply.
  2. Laravel 9 does not require PHP 8.1 it requires PHP 8.0.2

    If this a shared project and someone else with PHP 8.1 generated the composer.lock file (or indeed you locally have PHP 8.1 but the server has 8.0) you might end up with packages that require PHP 8.1. Composer resolves and installs packages based on the locally installed PHP version.

    You can override this behaviour and ensure everyone gets package deps based on the PHP version you expect to have on production if you use the platform config option in your composer.json e.g. add this to your composer.json

    "config": {
      "platform": {
         "php": "8.0.2" 
      }
    }
    

    Then run

    composer update
    

    this should try to fix your package versions to ones that work with PHP 8

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search