googleapis / google-api-php-client

A PHP client library for accessing Google APIs
Apache License 2.0
9.2k stars 3.52k forks source link

Clarifying the the difference between the PHP Version of the library and the release #2513

Closed greatBigMassive closed 7 months ago

greatBigMassive commented 8 months ago

Hello,

I need a bit of clarity please on how composer knows which PHP version of the google-api-client to install or how I specifiy which version of the api-client I want. For example, I have PHP 8.0 but I want api-client 7.4. The GitHub Composer install section does not seem to reference it.

Do you think it might be worth explaining how people know if Composer will install PHP 7.4, 8.0 or how to know which release of the api-client is the last release that supported 7.4 / 7.2 / ... Is it the case I simply have to know which release I have to install that is the last release that was 7.4? or 7.2? Is there a cross reference to help me know which release I need to install via composer to get the last release that supported 7.4?

As you can tell, I am a bit confused. I am sure if I am asking this there's going to be many more asking the same question so having a quick header for it or a paragraph in the install area might be nice / friendly.

At a guess, I have to use the composer "platform" option in the json file. Thanks in advance!

Adam

vishwarajanand commented 7 months ago

Composer checks the version of PHP locally installed and attempts to install the latest library that can satisfy requirements, ref composer's documentation.

If you are on a latest PHP version, say 8.2 and want to install packages for an older PHP version say 7.2, you can set it up like this in your composer.json:

{
   "config": {
      "platform": {
         "php": "7.2"
      }
   },
   "require": {
      "google/apiclient": "^2.0"
   }
}

Hope this helps.

greatBigMassive commented 7 months ago

That does help! Thank you!