PHP工匠服务在升级php7后要求出现致命错误 [英] Php artisan serve require fatal error after upgrading php7
问题描述
将php从7.0.14升级到7.0.26后,php artisan serve
引发此错误
After upgrading php from 7.0.14 to 7.0.26 php artisan serve
throws this error
警告:未知:无法打开流: 0行未知 致命错误:未知:无法打开所需的'/Applications/XAMPP/xamppfiles/htdocs/school-dashboard/public/server.php' (include_path ='.:')在第0行上为未知
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0 Fatal error: Unknown: Failed opening required '/Applications/XAMPP/xamppfiles/htdocs/school-dashboard/public/server.php' (include_path='.:') in Unknown on line 0
推荐答案
好吧,经过数小时的梳理,我终于找到了问题所在.
Ok, after hours of pulling my hair out I finally found out what the issue was.
在laravel 4 php artisan serve
中是在后台进行的
In laravel 4 php artisan serve
does this under the hood
<?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");
}
}
从本质上讲,这就是普通的php:
php -S 127.0.0.1:8000 -t public serve.php
-有关更多信息,请参阅服务器内置的php文档 .
That is essentially this in plain php:
php -S 127.0.0.1:8000 -t public serve.php
- see the docs for php built in server for more info.
在php 7.0.26之前,这很好用,而且很花哨,其中php -S
内置服务器的最后一个参数也被更改为标志,因此您必须像这样php -S 127.0.0.1:8000 -t public -f serve.php
来调用它.
And this worked well and dandy before php 7.0.26, where the last parameter for the php -S
built in server was changed to a flag as well, so you have to call it like this php -S 127.0.0.1:8000 -t public -f serve.php
.
如果要与php artisan serve
一起使用,则必须覆盖ServeCommand
并将fire()
方法的最后一行更改为:
If you want to serve it with php artisan serve
you will have to override the ServeCommand
and change the last line of the fire()
method to this:
passthru('"'.PHP_BINARY.'"'." -S {$host}:{$port} -t \"{$public}\" -f server.php");
passthru('"'.PHP_BINARY.'"'." -S {$host}:{$port} -t \"{$public}\" -f server.php");
或者您可以直接在ServeCommand
中进行更改,但是如果您进行作曲家更新或安装,则必须再次进行.
Or you can change it directly in the ServeCommand
, but if you do a composer update or install you will have to do it again.
这篇关于PHP工匠服务在升级php7后要求出现致命错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!