From a8b2ca0afe6844d6959a37d41685e67f67029e9b Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 14 Dec 2021 07:59:49 -0500 Subject: [PATCH 1/2] Allows to remove the `server.php` file --- .../Foundation/Console/ServeCommand.php | 10 ++++++---- src/Illuminate/Foundation/resources/server.php | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 src/Illuminate/Foundation/resources/server.php diff --git a/src/Illuminate/Foundation/Console/ServeCommand.php b/src/Illuminate/Foundation/Console/ServeCommand.php index 92f9ecf814af..ca205a7f8670 100644 --- a/src/Illuminate/Foundation/Console/ServeCommand.php +++ b/src/Illuminate/Foundation/Console/ServeCommand.php @@ -49,8 +49,6 @@ class ServeCommand extends Command */ public function handle() { - chdir(public_path()); - $this->line("Starting Laravel development server: http://{$this->host()}:{$this->port()}"); $environmentFile = $this->option('env') @@ -104,7 +102,7 @@ public function handle() */ protected function startProcess($hasEnvironment) { - $process = new Process($this->serverCommand(), null, collect($_ENV)->mapWithKeys(function ($value, $key) use ($hasEnvironment) { + $process = new Process($this->serverCommand(), public_path(), collect($_ENV)->mapWithKeys(function ($value, $key) use ($hasEnvironment) { if ($this->option('no-reload') || ! $hasEnvironment) { return [$key => $value]; } @@ -132,11 +130,15 @@ protected function startProcess($hasEnvironment) */ protected function serverCommand() { + $server = file_exists(base_path('server.php')) + ? base_path('server.php') + : __DIR__ . '/../resources/server.php'; + return [ (new PhpExecutableFinder)->find(false), '-S', $this->host().':'.$this->port(), - base_path('server.php'), + $server, ]; } diff --git a/src/Illuminate/Foundation/resources/server.php b/src/Illuminate/Foundation/resources/server.php new file mode 100644 index 000000000000..a44468135992 --- /dev/null +++ b/src/Illuminate/Foundation/resources/server.php @@ -0,0 +1,16 @@ + Date: Tue, 14 Dec 2021 13:00:26 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- src/Illuminate/Foundation/Console/ServeCommand.php | 2 +- src/Illuminate/Foundation/resources/server.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Foundation/Console/ServeCommand.php b/src/Illuminate/Foundation/Console/ServeCommand.php index ca205a7f8670..4f746bdd4587 100644 --- a/src/Illuminate/Foundation/Console/ServeCommand.php +++ b/src/Illuminate/Foundation/Console/ServeCommand.php @@ -132,7 +132,7 @@ protected function serverCommand() { $server = file_exists(base_path('server.php')) ? base_path('server.php') - : __DIR__ . '/../resources/server.php'; + : __DIR__.'/../resources/server.php'; return [ (new PhpExecutableFinder)->find(false), diff --git a/src/Illuminate/Foundation/resources/server.php b/src/Illuminate/Foundation/resources/server.php index a44468135992..b7fc7e79b236 100644 --- a/src/Illuminate/Foundation/resources/server.php +++ b/src/Illuminate/Foundation/resources/server.php @@ -1,6 +1,6 @@