{"id":23338810,"url":"https://github.com/mostafaznv/php-x-sendfile","last_synced_at":"2025-04-09T22:32:22.403Z","repository":{"id":50660818,"uuid":"270574782","full_name":"mostafaznv/php-x-sendfile","owner":"mostafaznv","description":"Serve large files using web server","archived":false,"fork":false,"pushed_at":"2023-02-04T20:44:42.000Z","size":28,"stargazers_count":53,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T00:25:22.737Z","etag":null,"topics":["laravel","php","x-sendfile"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mostafaznv.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-08T07:35:53.000Z","updated_at":"2024-12-27T16:18:45.000Z","dependencies_parsed_at":"2023-02-18T19:30:51.879Z","dependency_job_id":null,"html_url":"https://github.com/mostafaznv/php-x-sendfile","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostafaznv%2Fphp-x-sendfile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostafaznv%2Fphp-x-sendfile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostafaznv%2Fphp-x-sendfile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostafaznv%2Fphp-x-sendfile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mostafaznv","download_url":"https://codeload.github.com/mostafaznv/php-x-sendfile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248123655,"owners_count":21051509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","php","x-sendfile"],"created_at":"2024-12-21T03:16:53.897Z","updated_at":"2025-04-09T22:32:22.378Z","avatar_url":"https://github.com/mostafaznv.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP X-Sendfile\nServe large files using web server with support for laravel\n\n## Some features for X-Sendfile:\n- Support **Nginx**, **Apache**, **LiteSpeed**, **Lighttpd**\n- Automatic Server Type Detector\n- Configurable\n- Support Cache\n- Set Extra Headers\n- Compatible with Laravel\n\n----\nI develop in a open-source journey 🚀, I wish I lived in an environment where financial situation was fine and I could only focus on the path, but as you may know, life isn't perfect. \u003cbr\u003eSo if you end up using my packages, please consider making a donation, any amount would go along way and is much appreciated. 🍺\n\n[![Donate](https://mostafaznv.github.io/donate/donate.svg)](https://mostafaznv.github.io/donate)\n\n----\n\n## Requirements:\n- PHP \u003e=7.0.1\n- FileInfo Extension\n\n## Installation\nInstall using composer:\n```shell\ncomposer require mostafaznv/php-x-sendfile\n```\n\n\n## Laravel (Optional) \n1. ##### Register Provider and Facade in config/app.php:\n\u003e Don't need for Laravel 5.5+\n\n```php\n'providers' =\u003e [\n  Mostafaznv\\PhpXsendfile\\PhpXsendfileServiceProvider::class,\n],\n\n'aliases' =\u003e [\n  'Recaptcha' =\u003e Mostafaznv\\PhpXsendfile\\Facades\\PhpXsendfile::class,\n]\n```\n\n2. ##### Publish config file:\n```shell\nphp artisan vendor:publish --provider=\"Mostafaznv\\PhpXsendfile\\PhpXsendfileServiceProvider\"\n```\n\n## Usage\n```php\n\u003c?php\n\nnamespace App\\Controllers;\n\nuse Mostafaznv\\PhpXsendfile\\PhpXsendfile;\n\nclass DownloadController\n{\n    public function quickExample()\n    {\n        $path = '/files/Sample.mp4';\n\n        $xSendFile = new PhpXsendfile();\n        $xSendFile-\u003edownload($path);\n    }\n\n    public function completeExample()\n    {\n        $path = '/files/Sample.mp4';\n        // or full path\n        $path = public_path('files/Sample.mp4');\n\n        // optional\n        $config = [\n            'server' =\u003e null,\n            \n            'cache'                 =\u003e true,\n            'cache-control-max-age' =\u003e 2592000\n        ];\n\n        // set extra headers (optional)\n        $headers = [\n            'Header-Name' =\u003e 'Header-Value' // header('Header-Name: Header-Value')\n        ];\n\n        // set downloaded filename (optional, nullable)\n        $fileName = 'LargeVideoFile.mp4';\n\n        $xSendFile = new PhpXsendfile($config);\n        $xSendFile-\u003esetHeader($headers)-\u003edownload($path, $fileName);\n    }\n}\n\n```\n\n## Laravel Usage\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse Mostafaznv\\PhpXsendfile\\Facades\\PhpXsendfile; // or use PhpXsendfile;\n\nclass DownloadController extends Controller\n{\n    public function quickExample()\n    {\n        $path = public_path('files/zip.zip');\n\n        PhpXsendfile::download($path);\n\n        // or\n        \n        app('x-sendfile')-\u003edownload($path);\n    }\n\n    public function completeExample()\n    {\n        $path = public_path('files/zip.zip');\n\n        // set extra headers (optional)\n        $headers = [\n            'Header-Name' =\u003e 'Header-Value' // header('Header-Name: Header-Value')\n        ];\n\n        // set downloaded filename (optional, nullable)\n        $fileName = 'LargeVideoFile.mp4';\n\n        PhpXsendfile::setHeader($headers)-\u003edownload($path, $fileName);\n    }\n}\n```\n\u003e Note: to change configuration in laravel, open config/x-sendfile.php and set your own configurations.  \n\n\n## Config:\n| Key                   | Default                    | Type    | Description                                                                                                                       |\n|-----------------------|----------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------|\n| server                | null                       | string  | with null value, package will detect server type automatically \u003cbr\u003e supported: **Nginx**, **Apache**, **LiteSpeed**, **Lighttpd** |\n| base-path             | $_SERVER['DOCUMENT_ROOT']  | string  | defines base path of your project.                                                                                                |\n| cache                 | true                       | boolean | enable/disable for caching response                                                                                               |\n| cache-control-max-age | 2592000                    | integer | set maximum age of cache                                                                                                          |\n\n\n\n## Methods\n\n#### Download\n\n| Argument Index | Argument Name | Default | Type   | Description                                                         |\n|----------------|---------------|---------|--------|---------------------------------------------------------------------|\n| 0              | file          |         | string | relative (related to project index.php file) or absolute file path  |\n| 1              | fileName      | null    | string | user defined file name                                              |\n\n#### setHeader\n| Argument Index | Argument Name | Default | Example                            | Type  | Description                                                                 |\n|----------------|---------------|---------|------------------------------------|-------|-----------------------------------------------------------------------------|\n| 0              | headers       |         | ['Header-Name' =\u003e 'Header-Value')] | array | Key-Value array. \u003cbr\u003e **key** is header name \u003cbr\u003e **value** is header value |\n\n----\nI develop in a open-source journey 🚀, I wish I lived in an environment where financial situation was fine and I could only focus on the path, but as you may know, life isn't perfect. \u003cbr\u003eSo if you end up using my packages, please consider making a donation, any amount would go along way and is much appreciated. 🍺\n\n[![Donate](https://mostafaznv.github.io/donate/donate.svg)](https://mostafaznv.github.io/donate)\n\n----\n\n#### Credit and Thanks\nthis package inspired by [songlipeng2003's x-sendfile](https://github.com/songlipeng2003/php-x-sendfile).\n\n## Changelog\nRefer to the [Changelog](CHANGELOG.md) for a full history of the project.\n\n## License\nThis software released under [Apache License Version 2.0](LICENSE).\n\n(c) 2020 Mostafaznv, All rights reserved.\n\n\n-----\n### Sponsors\n\n[![JetBrains Logo (Main) logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://jb.gg/OpenSourceSupport)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostafaznv%2Fphp-x-sendfile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmostafaznv%2Fphp-x-sendfile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostafaznv%2Fphp-x-sendfile/lists"}