Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce the size of Google PHP library?

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?

like image 304
bng Avatar asked Jun 09 '18 14:06

bng


1 Answers

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"
        ]
    }
}

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
like image 50
Michael Mitch Avatar answered Oct 21 '22 00:10

Michael Mitch