contenir / storage
Framework-agnostic asset storage for Contenir CMS — local, S3-compatible, and Cloudflare Images adapters with a shared variant pipeline.
v0.2.2
2026-05-08 03:33 UTC
Requires
- php: ^8.1 || ^8.2 || ^8.3
- league/flysystem: ^3.0
- psr/log: ^3.0
Requires (Dev)
- cloudflare/sdk: ^1.1
- gumlet/php-image-resize: ^2.0
- league/flysystem-aws-s3-v3: ^3.0
- league/flysystem-memory: ^3.0
- phpunit/phpunit: ^11.0
- squizlabs/php_codesniffer: ^3.10
Suggests
- cloudflare/sdk: Required by the CloudflareImages adapter.
- gumlet/php-image-resize: Required by ImageResizer for local variant generation.
- league/flysystem-aws-s3-v3: Required by the S3 adapter.
README
Framework-agnostic asset storage for Contenir CMS.
Provides a unified StorageInterface for reading, writing, and listing
CMS-managed assets across local filesystem, S3-compatible object stores,
and Cloudflare Images, with a shared variant pipeline (responsive image
sizes derived from a single source).
Install
composer require contenir/storage
The package itself only requires league/flysystem and psr/log. Pull
in the optional dependencies for the adapter and features you use:
| You need | Also require |
|---|---|
| Local image variant generation | gumlet/php-image-resize |
| S3 adapter | league/flysystem-aws-s3-v3 |
| Cloudflare Images adapter | cloudflare/sdk |
Usage
use Contenir\Storage\StorageManager; use Contenir\Storage\Adapter\LocalFilesystem; use Contenir\Storage\VariantRegistry; $variants = new VariantRegistry(); $variants->register('admin-thumb', new Variant(width: 200, height: 200)); $manager = new StorageManager(); $manager->register('default', new LocalFilesystem( rootPath: '/var/www/uploads', publicUrl: 'https://example.com/uploads', variants: $variants, )); $backend = $manager->get('default'); $url = $backend->url('logos/site.png', variant: 'admin-thumb'); // Convenience for the canonical admin-thumbnail variant. Returns null // when the profile doesn't declare it or the asset hasn't been // materialised yet — CMS UIs can call this on any profile and fall back // to whatever URL they have on hand. $thumb = $backend->thumbnailUrl('logos/site.png');
See src/Adapter/ for the full set of adapters and tests/ for end-to-end
examples against each.