Download the PHP package zenstruck/filesystem without Composer
On this page you can find all versions of the php package zenstruck/filesystem. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zenstruck/filesystem
More information about zenstruck/filesystem
Files in zenstruck/filesystem
Package filesystem
Short Description Wrapper for league/flysystem with alternate API and added functionality.
License MIT
Homepage https://github.com/zenstruck/filesystem
Informations about the package filesystem
zenstruck/filesystem
This library is a wrapper for the excellent league/flysystem File Storage Abstraction library. It provides an alternate API with the following major changes:
- The main difference is the concept of
Image
objects. These are wrappers for an individual filesystem node and provide info, metadata and more features. These can be passed around (ie sent to your templates) or even used as Doctrine Types. - Combine certain Flysystem methods. For example,
delete()
removes both files and directories,write()
can write both strings and streams (+ more). - Eases the use of filesystem files as real, local files. Many 3rd party libraries that manipulate files require local files.
Additionally, the following features are provided:
- Filesystem wrappers to add additional functionality (ie
MultiFilesystem
, andLoggableFilesystem
). - Powerful testing helpers.
TarFile
representing a local zip/tar(.gz/bz2) file that acts as both a filesystem and a real file.- Doctrine Integration.
- Symfony Integration
- Custom Responses
- Validators
- Bundle to help configure filesystem services, wire the Doctrine integration and additional testing helpers.
Installation
API
Filesystem
Node
Interface: Zenstruck\Filesystem\Node
.
File
Interface: Zenstruck\Filesystem\Node\File
(extends Node
).
[!NOTE] See
zenstruck/temp-file
for more details aboutFile::tempFile()
.[!NOTE] See
zenstruck/stream
for more details aboutFile::stream()
.
PendingFile
Class: Zenstruck\Filesystem\Node\File\PendingFile
(extends \SplFileInfo
and implements File
).
Image
Interface: Zenstruck\Filesystem\Node\File\Image
(extends File
).
[!NOTE] See
zenstruck/image
for more details aboutImage::transform()
andImage::thumbHash()
.
PendingImage
Class: Zenstruck\Filesystem\Node\File\Image\PendingImage
(extends Image
).
Directory
Interface: Zenstruck\Filesystem\Node\Directory
(extends Node
).
[!NOTE] Most of the advanced filters require
symfony/finder
(composer require symfony/finder
).
Filesystems
FlysystemFilesystem
Filesystem DSNs
DSN | Adapter |
---|---|
%kernel.project_dir%/public/files |
LocalAdapter |
in-memory: |
InMemoryFilesystemAdapter (requires league/flysystem-memory ) |
in-memory:name |
Static InMemoryFilesystemAdapter (requires league/flysystem-memory ) |
flysystem+ftp://user:[email protected]/root |
FtpAdapter (requires league/flysystem-ftp ) |
flysystem+ftps://user:[email protected]/root |
FtpAdapter (requires league/flysystem-ftp ) |
flysystem+sftp://user:[email protected]:22/root |
SftpAdapter (requires league/flysystem-sftp-v3 ) |
flysystem+s3://accessKeyId:accessKeySecret@bucket/prefix#us-east-1 |
AsyncAwsS3Adapter /AwsS3V3Adapter (requires league/flysystem-async-aws-s3 or league/flysystem-aws-s3-v3 ) |
readonly:<any-above-dsn> |
ReadOnlyFilesystemAdapter (requires league/flysystem-read-only ) |
ScopedFilesystem
MultiFilesystem
CacheFilesystem
[!NOTE] A
psr/cache-implementation
is required.
LoggableFilesystem
[!NOTE] A
psr/log-implementation
is required.
EventDispatcherFilesystem
[!NOTE] A
psr/event-dispatcher-implementation
is required.[!NOTE] See event classes to see what is made available to them.
[!NOTE] The
Pre*Event
properties can be manipulated.
ZipFile
[!NOTE]
league/flysystem-ziparchive
is required (composer require league/flysystem-ziparchive
).
This is a special filesystem wrapping a local zip archive. It acts as both a Filesystem
and \SplFileInfo
object:
When creating without a path, creates a temporary archive file (that's deleted at the end of the script):
Write operations can be queued and committed via a transaction:
Static helper for quickly creating zip
archives:
TarFile
[!NOTE]
league/flysystem-read-only
is required (composer require league/flysystem-read-only
).
This is a special filesystem wrapping an existing local tar(.gz/bz2) archive. It acts as both a readonly
Filesystem
and \SplFileInfo
object:
TestFilesystem
This filesystem wraps another and provides assertions for your tests. When using PHPUnit, these assertions are converted to PHPUnit assertions.
[!NOTE]
zenstruck/assert
is required to use the assertions (composer require --dev zenstruck/assert
).
InteractsWithFilesystem
Use the InteractsWithFilesystem
trait in your unit tests to quickly provide an in-memory filesystem.
[!NOTE] By default,
league/flysystem-memory
is required (composer require --dev league/flysystem-memory
).
FilesystemProvider
To provide your own filesystem for your tests, have your tests (or base test-case) implement FilesystemProvider
:
[!NOTE] By default, the provided filesystem isn't reset before each test. See the
ResetFilesystem
to enable this behaviour.
FixtureFilesystemProvider
A common requirement for filesystem tests, is to have a set of known fixture files that are used in your tests.
Have your test's (or base test-case) implement FixtureFilesystemProvider
to provide in your tests:
[!NOTE] If the
league/flysystem-read-only
adapter is available, it's used to wrap your fixture adapter to ensure you don't accidentally overwrite/delete your fixture files (composer require --dev league/flysystem-read-only
).
ResetFilesystem
If using your own FilesystemProvider
, you can use the ResetFilesystem
trait to
purge your filesystem before each test.
Symfony Integration
Responses
Helpful custom Symfony responses are provided.
FileResponse
Take a filesystem File
and send as a response:
ArchiveResponse
Zip file(s) and send as a response. Can be created with a local file, local directory, instance of
Directory
.
Validators
Both a PendingImage
validator is provided. The constraints have
the same API as Symfony's native File
and
Image
constraints.
Bundle
Configuration
Services
Serializer
Form Types
PendingFileType
PendingImageType
Commands
zenstruck:filesystem:purge
Routing
Public Url Route
Temporary Url Route
Transform Url Route
RouteTransformUrlGenerator
Doctrine Integration
Functional/Integration Testing
TODO: Note about Mock::pendingFile()/pendingImage()
.
TODO: Note about Foundry\LazyMock::pendingFile()/pendingImage()
.
Testing Performance
Full Default Bundle Configuration
Backward Compatibility Promise
This library follows Symfony's BC Promise with the following exceptions:
Zenstruck/Filesystem
and any implementations are considered internal for implementation/extension.Zenstruck/Filesystem/Node
and any implementations are considered internal for implementation/extension.
All versions of filesystem with dependencies
league/flysystem Version ^3.11
zenstruck/image Version ^1.0
zenstruck/stream Version ^1.2
zenstruck/temp-file Version ^1.2.1