2017 © Pedro Peláez
 

library file-serving

Serve files to the browser that are not available directly

image

gisostallenberg/file-serving

Serve files to the browser that are not available directly

  • Tuesday, October 4, 2016
  • by gisostallenberg
  • Repository
  • 2 Watchers
  • 2 Stars
  • 12,020 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 3 Open issues
  • 7 Versions
  • 5 % Grown

The README.md

file-serving

Serve files to the browser that are not available directly, (*1)

Installation

composer require gisostallenberg/file-serving

Usage example

Add in serve-it/.htaccess, (*2)

RewriteRule .*  file-serving.php [QSA,L]

file-serving.php content, (*3)

<?php
require_once __DIR__ . '/../../vendor/autoload.php';

use GisoStallenberg\FileServing\FileServer;

$fileserver = new FileServer('../../serve-me/', 'serve-it/');
$fileserver->serve(); // will server http://example.com/serve-it/example.txt when ../serve-me/example.txt exists, gives a 404 otherwise
<?php
require_once __DIR__ . '/../../vendor/autoload.php';

use GisoStallenberg\FileServing\FileServer;
use Symfony\Component\HttpFoundation\Response;

$fileserver = new FileServer('../../serve-me/', 'serve-it/');
$response = $fileserver->getResponse(); // do not serve yet

if ($response->getStatusCode() === Response::HTTP_NOT_FOUND) {
    $fileserver = new FileServer('../../serve-other-dir/', 'serve-it/'); // check another directory
    $response = $fileserver->getResponse();
}

$response->send();

Credits

Niels Nijens (https://github.com/niels-nijens/), (*4)

The Versions

04/10 2016

dev-master

9999999-dev

Serve files to the browser that are not available directly

  Sources   Download

MIT

The Requires

 

The Development Requires

by Giso Stallenberg

04/10 2016

1.2.0

1.2.0.0

Serve files to the browser that are not available directly

  Sources   Download

MIT

The Requires

 

The Development Requires

by Giso Stallenberg

04/03 2016

1.1.0

1.1.0.0

Serve files to the browser that are not available directly

  Sources   Download

MIT

The Requires

 

by Giso Stallenberg

03/03 2016

1.0.3

1.0.3.0

Serve files to the browser that are not available directly

  Sources   Download

MIT

The Requires

 

by Giso Stallenberg

03/03 2016

1.0.2

1.0.2.0

Serve files to the browser that are not available directly

  Sources   Download

MIT

The Requires

 

by Giso Stallenberg

03/03 2016

1.0.1

1.0.1.0

Serve files to the browser that are not available directly

  Sources   Download

MIT

The Requires

 

by Giso Stallenberg

03/03 2016

1.0.0

1.0.0.0

Serve files to the browser that are not available directly

  Sources   Download

MIT

The Requires

 

by Giso Stallenberg