Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 96a93e9

Browse files
author
Jeroen van Meeuwen
committed
Remove public path -> document root change
1 parent 428e5d1 commit 96a93e9

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

config/swoole_http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
'server' => [
1313
'host' => env('SWOOLE_HTTP_HOST', '127.0.0.1'),
1414
'port' => env('SWOOLE_HTTP_PORT', '1215'),
15-
'document_root' => base_path('public'),
15+
'public_path' => base_path('public'),
1616
// Determine if to use swoole to respond request for static files
1717
'handle_static_files' => env('SWOOLE_HANDLE_STATIC', true),
1818
'access_log' => env('SWOOLE_HTTP_ACCESS_LOG', false),

src/Server/Manager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ public function onRequest($swooleRequest, $swooleResponse)
205205
$this->resetOnRequest();
206206
$sandbox = $this->app->make(Sandbox::class);
207207
$handleStatic = $this->container->make('config')->get('swoole_http.server.handle_static_files', true);
208-
$documentRoot = $this->container->make('config')->get('swoole_http.server.document_root', base_path('public'));
208+
$publicPath = $this->container->make('config')->get('swoole_http.server.public_path', base_path('public'));
209209

210210
try {
211211
// handle static file request first
212-
if ($handleStatic && Request::handleStatic($swooleRequest, $swooleResponse, $documentRoot)) {
212+
if ($handleStatic && Request::handleStatic($swooleRequest, $swooleResponse, $publicPath)) {
213213
return;
214214
}
215215
// transform swoole request to illuminate request

src/Transformers/Request.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ protected static function transformServerParameters(array $server, array $header
175175
*
176176
* @param \Swoole\Http\Request $swooleRequest
177177
* @param \Swoole\Http\Response $swooleResponse
178-
* @param string $documentRoot
178+
* @param string $publicPath
179179
*
180180
* @return boolean
181181
*/
182-
public static function handleStatic($swooleRequest, $swooleResponse, string $documentRoot)
182+
public static function handleStatic($swooleRequest, $swooleResponse, string $publicPath)
183183
{
184184
$uri = $swooleRequest->server['request_uri'] ?? '';
185185
$extension = strtok(pathinfo($uri, PATHINFO_EXTENSION), '?');
186-
$fileName = @realpath($documentRoot . $uri);
186+
$fileName = @realpath($publicPath . $uri);
187187

188188
if (!$fileName) {
189189
return false;
@@ -193,7 +193,7 @@ public static function handleStatic($swooleRequest, $swooleResponse, string $doc
193193
return false;
194194
}
195195

196-
if (substr($fileName, 0, strlen($documentRoot)) != $documentRoot) {
196+
if (substr($fileName, 0, strlen($publicPath)) != $publicPath) {
197197
return false;
198198
}
199199

tests/Server/ManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ManagerTest extends TestCase
6161
'swoole_http.tables' => [],
6262
'swoole_http.providers' => [],
6363
'swoole_http.resetters' => [],
64-
'swoole_http.server.document_root' => '/',
64+
'swoole_http.server.public_path' => '/',
6565
];
6666

6767
public function testGetFramework()

0 commit comments

Comments
 (0)