azuracast / flysystem-v2-extensions
Extensions to Flysystem V2 functionality.
Fund package maintenance!
AzuraCast
Open Collective
Patreon
Installs: 11 800
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: ^7.4 || ^8.0
- league/flysystem: ^2.1
Requires (Dev)
- league/flysystem-aws-s3-v3: ^2.0
- php-parallel-lint/php-console-highlighter: ^0.5.0
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/phpstan: ^0.12.26
- roave/security-advisories: dev-latest
- spatie/flysystem-dropbox: ^2.0
Suggests
- league/flysystem-aws-s3-v3: AWS S3 API version 3 adapter for Flysystem V2.
- spatie/flysystem-dropbox: Dropbox adapter for Flysystem V2.
README
This library contains extended functionality for version 2 of the Flysystem file abstraction library.
Much of the functionality is intended to restore a user experience similar to Flysystem V1 and to allow for easier customization of Flysystem for third-party purposes.
Any portion of the extended classes can be used interchangeably with the base Flysystem classes.
Added Functionality
Extended Adapters
-
getMetadata Function: Supported adapters have had a
getMetadata
call added to replace the need for separate metadata calls, in keeping with the functionality of Flysystem 1.x. This also reduces redundant API calls if you need the full metadata for a file and use thegetMetadata
function at the Filesystem level. -
Lazy-Loading StorageAttributes: To ensure all metadata is available in the
StorageAttributes
return object, even if some items may be more computationally expensive, some metadata attributes can be supplied as callable functions that resolve when called. This is currently only the case for thevisibility
attribute, because it's the most computationally intensive one. -
On-Disk Adapter Optimizations: The local, on-disk adapter implements a new
LocalAdapterInterface
with a single method:getLocalPath
; if your application has optimizations built in for on-disk filesystems, this allows you to immediately identify if the filesystem you're using is on-disk or not.
Filesystem Changes
-
Additional metadata functions are exposed:
getMetadata
to return any availableStorageAttributes
in one objectisFile
, which corresponds to theisFile()
function inStorageAttributes
isDir
, which corresponds to theisDir()
function inStorageAttributes
-
A new method,
getAdapter
, is exposed that allows direct access to the underlying adapter interface. -
Helper classes and methods to further distinguish between local and remote filesystems:
LocalFilesystem
intended for use with theLocalFilesystemAdapter
RemoteFilesystem
with an optional$local_path
parameter, intended for remote adapters that still may need a temporary local file to be created for interaction with other scripts,upload
, a helper which copies from the local disk to the destination filesystem,download
, a helper which copies from the source filesystem to the local disk,withLocalFile
, a helper which supplies a callable function with a path to a file that is guaranteed to be on-disk, even if the filesystem itself is remote.
Supported Adapters
Currently, this library is a monorepo consisting of all adapters used by the primary application making use of this library:
- Local: A local, on-disk filesystem.
- AwsS3: A remote filesystem for cloud storage supporting the AWS S3 storage API.
- Dropbox: A remote filesystem for cloud storage on the Dropbox application.