Skip to content

Commit ddd727e

Browse files
committed
set custom/absolute base-path #2
1 parent f3dde64 commit ddd727e

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,12 @@ class DownloadController extends Controller
134134
135135

136136
## Config:
137-
| Key | Default | Type | Description |
138-
|-----------------------|---------|---------|-----------------------------------------------------------------------------------------------------------------------------------|
139-
| server | null | string | with null value, package will detect server type automatically <br> supported: **Nginx**, **Apache**, **LiteSpeed**, **Lighttpd** |
140-
| cache | true | boolean | enable/disable for caching response |
141-
| cache-control-max-age | 2592000 | integer | set maximum age of cache |
137+
| Key | Default | Type | Description |
138+
|-----------------------|----------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------|
139+
| server | null | string | with null value, package will detect server type automatically <br> supported: **Nginx**, **Apache**, **LiteSpeed**, **Lighttpd** |
140+
| base-path | $_SERVER['DOCUMENT_ROOT'] | string | defines base path of your project. |
141+
| cache | true | boolean | enable/disable for caching response |
142+
| cache-control-max-age | 2592000 | integer | set maximum age of cache |
142143

143144

144145

@@ -169,12 +170,13 @@ this package inspired by [songlipeng2003's x-sendfile](https://github.com/songli
169170
## Changelog
170171
Refer to the [Changelog](CHANGELOG.md) for a full history of the project.
171172

172-
## License
173-
This software released under [Apache License Version 2.0](LICENSE).
173+
-----
174+
## Sponsors
174175

175-
(c) 2020 Mostafaznv, All rights reserved.
176+
[![JetBrains Logo (Main) logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://jb.gg/OpenSourceSupport)
176177

177178
-----
178-
### Sponsors
179+
## License
180+
This software released under [Apache License Version 2.0](LICENSE).
179181

180-
[![JetBrains Logo (Main) logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://jb.gg/OpenSourceSupport)
182+
(c) 2020 Mostafaznv, All rights reserved.

config/config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
return [
44
'server' => null,
55

6+
'base-path' => $_SERVER['DOCUMENT_ROOT'],
7+
68
'cache' => true,
79
'cache-control-max-age' => 2592000
810
];

src/PhpXsendfile.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ protected function pathToUri($path): string
267267
*/
268268
protected function basePath(): string
269269
{
270+
if (isset($this->config['base-path']) and $this->config['base-path']) {
271+
return realpath($this->config['base-path']);
272+
}
273+
270274
return $_SERVER['DOCUMENT_ROOT'];
271275
}
272276
}

0 commit comments

Comments
 (0)