11

The size of Google php API Library is very large. I just want to send an email with the library. How can I reduce its size?

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
bng
  • 109
  • 5

2 Answers2

10

To reduce the vendor library size, google/apiclient offers a configuration on composer.json to run a cleanup script post-update.

This way you can specify only your required apis,
to reduce storage size on production.
Especially if you are going to use it on tighter storage requirement environment, like serverless architecture.

Reference: https://packagist.org/packages/google/apiclient

{
    "require": {
        "google/apiclient": "^2.7"
    },
    "scripts": {
        "post-update-cmd": "Google\\Task\\Composer::cleanup"
    },
    "extra": {
        "google/apiclient-services": [
            "Drive",
            "YouTube"
        ]
    }
}

for no services at all (for instance you're only using the API to verify the integrity of a JWT ID token) the extra.google/apiclient-services array/list needs to contain an empty string

"extra": {
    "google/apiclient-services": [ "" ]
}

You may want remove the entire apiservices folder first, and then do a composer update, if you already installed a full set of api.

$ rm -r vendor/google/apiclient-services
$ composer update
Mark
  • 2,196
  • 1
  • 14
  • 8
Michael Mitch
  • 789
  • 6
  • 14
0

The reason the library is large is that it contains all of the classes for all of the Google Discovery api's i think there are around 120 of them.

The only way i know of to reduce the size is to remove all of the APIs you dont need. check the Google/Service directory. Delete the apis you are not planning on using.

Leave everything else.

There is also the option of

composer install --no-dev
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • what about `bin\ cache\ composer\ dealerdirect\ doctrine\ firebase\ justinrainbow\ league\ monolog\ myclabs\ phpcompatibility\ phpdocumentor\ phpseclib\ phpspec\ phpunit\ psr\ ralouphie\ sebastian\ seld\ squizlabs\ symfony\ webmozart\` can I get rid of these? – mevsme Nov 07 '20 at 00:37
  • try if it breaks put them back? – Linda Lawton - DaImTo Nov 07 '20 at 10:56
  • 1
    `composer install --no-dev` helped a lot, I didn't know about this option – mevsme Nov 07 '20 at 12:18