好吧,经过几个小时的拔毛,我终于发现了问题所在.
在laravel 4 php artisan serve中,这是在引擎盖下
<?php
namespace Illuminate\Foundation\Console;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
class ServeCommand extends Command {
public function fire()
{
$this->checkPhpVersion();
chdir($this->laravel['path.base']);
$host = $this->input->getOption('host');
$port = $this->input->getOption('port');
$public = $this->laravel['path.public'];
$this->info("Laravel development server started on http://{$host}:{$port}");
passthru('"'.PHP_BINARY.'"'." -S {$host}:{$port} -t \"{$public}\" server.php");
}
}
Run Code Online (Sandbox Code Playgroud)
这基本上是在普通的PHP中:
php -S 127.0.0.1:8000 -t public serve.php- 请参阅服务器内置的php文档以获取更多信息.
这在php 7.0.26之前运行良好且花花公子,其中php -S内置服务器的最后一个参数也改为标志,所以你必须像这样调用它php -S 127.0.0.1:8000 -t public -f serve.php.
如果你想与它一起服务,php artisan serve你必须覆盖ServeCommand并将fire()方法的最后一行更改为:
passthru('"'.PHP_BINARY.'"'." -S {$host}:{$port} -t \"{$public}\" -f server.php");
或者您可以直接在其中更改它ServeCommand,但如果您进行作曲家更新或安装,则必须再次执行此操作.