Files
content/Readme.md

46 lines
1.5 KiB
Markdown

# IQParts/Content
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/IQParts/content/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/IQParts/content/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/IQParts/content/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/IQParts/content/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/IQParts/content/badges/build.png?b=master)](https://scrutinizer-ci.com/g/IQParts/content/build-status/master)
### 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'
```