Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Illuminate/Foundation/Console/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class ServeCommand extends Command
*/
public function handle()
{
chdir(public_path());

$this->line("<info>Starting Laravel development server:</info> http://{$this->host()}:{$this->port()}");

$environmentFile = $this->option('env')
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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,
];
}

Expand Down
16 changes: 16 additions & 0 deletions src/Illuminate/Foundation/resources/server.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$publicPath = getcwd();

$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists($publicPath.$uri)) {
return false;
}

require_once $publicPath.'/index.php';