When the need for horizontal scaling arises, multiple services, servers and workers which do not operate from the same physical machine, should be able to access a common filesystem. The local filesystems are not an option anymore and cloud-based storage services are the defacto approach for file storage these days.

There are a lot of options like Aws S3, Dropbox or Azure Blob storage and each of these services provides it's own SDK. Directly using an sdk, can easyli generate "vendor lock" and tight coupling which will be a nightmare to change in the future. Apart from the fact that the developers will need to learn the vendor SDK, they will also need to work with php's native file manipulations functions and methods which are not very developer friendly.

Thankfully there is a better aproach in the PHP ecosystem.

The league/flysystem is filesystem abstraction library, which adds an abstraction layer between the client code and the actual filesystem. That helps making the filesystem an implementations detail and the business code independent from the filesystem.

The basic idea is that your code does not communicate directly with the SDK, but with the flysystem. The flysystem then, depending on the configuraion it was provided comunicates with the storage service.

The flysystem uses the adapter pattern in its core. There is a list of available adapters: Local, Aws S3, Azure to name a few and they slightly differ in their configuration, but the flysystem provides a single generic API regardless of which one you use.