msgraph-sdk-php icon indicating copy to clipboard operation
msgraph-sdk-php copied to clipboard

The library is huge and I have some questions about this.

Open anthonylex opened this issue 1 year ago • 6 comments

So when installing this library it installs a huge amount of files (approx 30k). This is causing thinks like psalms memory usage to jump from sub 1G to almost 10G. Are there any plans to be able to have some kind of segmenting of the api? At the moment our use case cares only about using the subscriptions and messages resources but were having to include so much more as its all or nothing.

anthonylex avatar Feb 20 '24 12:02 anthonylex

Is there any advice on this?

anthonylex avatar Mar 04 '24 09:03 anthonylex

We have the exactly same problem

etremblay avatar Mar 13 '24 18:03 etremblay

v2 of the PHP SDK was written by a machine: Kiota, a script that Microsoft has written so that they can in turn use to automatically build SDKs based on OpenAPI specifications. You can read more about it here:

https://learn.microsoft.com/en-gb/openapi/kiota/quickstarts/php

No human in their right mind would write an SDK with 30k files.

This is also why v2 is a lot more work to implement than v1, to the point that we stopped rollout of v2 and reverted back to v1.

dearsina avatar Mar 14 '24 07:03 dearsina

For thoses it may help, we could work around the problem using https://github.com/liborm85/composer-vendor-cleaner

The deletion of unused files take a few seconds during the composer install/update but it fix the memory consumption by psalm.

{
  "microsoft/microsoft-graph": [
    "src/Generated/**",
    "!src/Generated/*",
    "!src/Generated/Models/**",
    "!src/Generated/Users/Item/*",
    "!src/Generated/Users/Item/Contacts/**",
  ]
}

etremblay avatar Mar 15 '24 13:03 etremblay

This is also a problem when you use Composer's autoloader optimization.

I frequently get timeout errors because the generation takes more than 5 minutes (i.e. the default Composer timeout). And the generated autoloader is huge: more than 9 Mb... loaded/parsed with each request. Insane!

I strongly recommend to disable the optimized autoloader when using the Graph SDK.

cedx avatar Mar 17 '24 13:03 cedx

Prior art for a cleanup task in composer after install: https://github.com/googleapis/google-api-php-client?tab=readme-ov-file#cleaning-up-unused-services

The request builder classes are already organized by service. It should not be too hard to target specific directories to keep as the dependencies between them seem to be non-existent (except for Models which could be left intact).

pylafleur avatar Apr 15 '24 15:04 pylafleur