2017 © Pedro Peláez
 

library web-resource

image

timostamm/web-resource

  • Tuesday, March 27, 2018
  • by timostamm
  • Repository
  • 1 Watchers
  • 0 Stars
  • 57 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 19 % Grown

The README.md

PHP Web Resources

build Packagist PHP Version GitHub tag License, (*1)

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)

Example

// 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

The Versions

27/03 2018

dev-master

9999999-dev

  Sources   Download

AGPL-3.0

The Requires

 

The Development Requires