-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fileserver class * README * composer requirements
- Loading branch information
1 parent
de51a9d
commit a568798
Showing
5 changed files
with
145 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
composer.phar | ||
/vendor/ | ||
|
||
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file | ||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file | ||
# composer.lock | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,39 @@ | ||
# file-serving | ||
Serve files to the browser that are not available directly | ||
|
||
## Installation | ||
```bash | ||
composer require gisostallenberg/file-serving | ||
``` | ||
|
||
## Usage example | ||
```php | ||
<?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 | ||
<?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/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters