42 lines
1.1 KiB
Markdown
42 lines
1.1 KiB
Markdown
# IQParts/Content
|
|
|
|
### Installation
|
|
`composer require iqparts/content`
|
|
|
|
### Content
|
|
This library is a small wrapper around [League\Flysystem](https://github.com/thephpleague/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
|
|
``` php
|
|
// 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'
|
|
|
|
``` |