Flysystem Path Prefixing
A Flysystem adapter decorator that transparently prefixes every path with a fixed root.
Repository Health
Technical Analysis
Flysystem Path Prefixing is a small adapter decorator for League Flysystem that transparently prepends a fixed path prefix to every filesystem operation. You wrap any existing Flysystem adapter, give it a base directory, and all reads, writes, listings, and deletes are scoped beneath that prefix without changing the calling code. It is the official way to confine a filesystem to a subdirectory or to run multiple logically separated stores on top of a single underlying adapter.
What You Get
- A
PathPrefixedAdapterthat wraps any Flysystem v3 adapter and applies a fixed prefix to all paths - Transparent prefixing across the full filesystem API — read, write, list, move, copy, and delete
- A drop-in way to sandbox or namespace storage without touching your application’s file-access code
Common Use Cases
- Confining a filesystem to a specific subdirectory so callers cannot escape a base path
- Running several logically isolated stores on top of one shared underlying adapter
- Adding a tenant- or environment-specific root prefix to an existing storage configuration
Under The Hood
Architecture - The package provides a single PathPrefixedAdapter that implements Flysystem’s FilesystemAdapter interface and delegates to an inner adapter. It uses Flysystem’s PathPrefixer to join the configured prefix with each incoming path on the way in and to strip it from listings on the way out, so both directions of the API stay consistent. Tech Stack - Written for PHP 8.0.2+ and depends only on league/flysystem (^3.10). It uses PSR-4 autoloading under the League\Flysystem\PathPrefixing namespace and is distributed as a read-only subtree split of the main Flysystem monorepo. Code Quality - Despite its small size, the adapter ships with a PathPrefixedAdapterTest covering the decorated operations, and it follows the same coding standards and CI as the rest of the League Flysystem project. API Design - Usage is a single constructor call — new PathPrefixedAdapter($innerAdapter, 'some/prefix') — after which the wrapped filesystem behaves identically to any other, keeping the abstraction invisible to the rest of the codebase.