google-api-php-client
google-api-php-client copied to clipboard
Cleaning up unused services - optimize-autoloader
First - nice feature, in version 2.7 to clean up unused services. Instructions from README.md are fine for dev env, on prod, with "typical" usage is not working.
Environment details
- OS: any
- PHP version: any
- Package name and version:
google/apiclient 2.7
Steps to reproduce
- Create repository with
composer.json(use the one from README.md or see below) - Run
composer update -o(note-oflag to optimize autoloader) - Check
vendor/composer/autoload_classmap.php(it still contains all services)
Also, another case, for prod deploy, is to run composer install -o when we have present composer.lock.
Even if there is no vendor the command to clear services is not gonna run (unless we add also: "post-install-cmd": "Google_Task_Composer::cleanup")
The problem is that services are removed after building the autoload files, so we need to re-run dump-autoload, to get these files updated. I think it should be noted in README if it cannot be solved by the script.
Code example
composer.json content (the same as in README.md):
{
"require": {
"google/apiclient": "^2.7"
},
"scripts": {
"post-update-cmd": "Google_Task_Composer::cleanup"
},
"extra": {
"google/apiclient-services": [
"Drive",
"YouTube"
]
}
}
Removed ALL services except Youtube and Drive ?
"require": {
"google/apiclient": "^2.7"
},
"scripts": {
"post-update-cmd": "Google_Task_Composer::cleanup"
},
"extra": {
"google/apiclient-services": [
"Calendar",
"Iam",
"IAMCredentials",
"Oauth2",
"SearchConsole",
"YouTube"
]
}
I tried the following, but it does not work:
"extra": {
"google/apiclient-services": [
"Analytics",
"AnalyticsReporting"
]
}
I'm having issues with: Class "Google_Service_AnalyticsReporting" not found, form this guide
Finally composer saying:
[InvalidArgumentException] Google service "AnalyticsReporting" does not exist or was removed previously