dev-master
9999999-dev
AGPL-3.0
The Requires
- php >=5.5
- symfony/http-foundation >=2.8
The Development Requires
- phpunit/phpunit ~6.3
- symfony/process >=2.8
- mikey179/vfsstream ^1.6
Wallogit.com
2017 © Pedro Peláez
A collection of classes that represent resources, suited for delivery to a HTTP client., (*2)
The benefit of these classes is a common interface that bundles the data stream with a bunch of metadata like mimetype, modification date, etc., (*3)
This abstraction makes caching, lazy processing, media type conversion and other pipelined operations much more convenient than handling files., (*4)
// In a Symfony Controller:
$res = Resource::fromFile('dir/my-file.txt');
$res->getMimetype(); // guessed mimetype
return new ResourceResponse($res);
// Fetch a resource from an URL:
$res = Resource::fromUrl('http://foo.bar/my-file.txt');
$res->getMimetype(); // mimetype from server
$res->getLastModified(); // modification date from server
// Overriding a mimetype and the file name:
$res = Resource::fromFile('dir/my-file.txt', [
'mimetype' => 'applicatio/octet-stream',
'filename' => 'text.txt'
]);
return new ResourceResponse($res); // will also set the appropriate content-disposition header
AGPL-3.0