1.1 KiB
1.1 KiB
IQParts/Content
Installation
composer require iqparts/content
Content
This library is a small wrapper around League\Flysystem. This library lets you do anything that Flysystem already can, but uses its own objects with some extra functions.
Resolver
This library also includes an AssetResolver which returns a PSR-7 response if the file exists on the filesystem.
Usage
// Filesystem
$fs = new IQParts\Content\Filesystem(
new League\Flysystem\AdapterInterface(),
new League\Flysystem\Config()
);
// AssetResolver
$resolver = new AssetResolver($fs);
if ($resolver->exists('my-file.txt') {
// PSR-7 $response
$response = $resolver->resolve(
$request, // PSR-7 request
$response, // PSR-7 response
$cacheControl // CacheControl object,
$inline // Inline or as attachment
);
}
// MimeDetector
$mimetype = (new MimeDetector([
'my-mime' => 'my-mimetype'
]))->detectFromExtension('document.pdf');
$mimetype = 'application/pdf'