Initial commit IQParts\Content

This commit is contained in:
2018-03-01 18:41:55 +01:00
commit 349fa9c003
23 changed files with 1535 additions and 0 deletions

42
Readme.md Normal file
View File

@@ -0,0 +1,42 @@
# 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'
```