Laravel 错误 - 未知:需要打开失败'。./public' (include_path='.;C:\php\pear\') in Unknown on line 0

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31779434/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:06:17  来源:igfitidea点击:

Laravel error - Unknown: Failed opening required '. ./public' (include_path='.;C:\php\pear\') in Unknown on line 0

phplaravel

提问by wintoch

I'm working on Laravel 5 and I'm using PHP function php -S localhost:8888 folder-name - tto show the web site.

我在 Laravel 5 上工作,我正在使用 PHP 函数php -S localhost:8888 folder-name - t来显示网站。

Everything is working fine until I updated to Window 10. Now, I try to run the project in my browser, I get a blank page and this message in my cmd:

一切正常,直到我更新到 Window 10。现在,我尝试在我的浏览器中运行该项目,我得到一个空白页面,并在我的消息中显示cmd

[Mon Aug 03 00:17:05 2015] PHP Fatal error: Unknown: Failed opening required 'public' (include_path='.;C:\php\pear\') in Unknown on line 0

[Mon Aug 03 00:17:05 2015] PHP Fatal error: Unknown: Failed opening required 'public' (include_path='.;C:\php\pear\') in Unknown on line 0

What is going wrong?

出了什么问题?

回答by jeffwtribble

It sounds like a permissions issue. I don't have much experiencing working with Laravel on Windows, but I just fixed a similar issue on an Ubuntu box.

听起来像是权限问题。我没有太多在 Windows 上使用 Laravel 的经验,但我只是在 Ubuntu 机器上修复了一个类似的问题。

The source of trouble for me was that I installed composer as root, so I had to remove ./vendor, change the owner and group of ~/.composerto ubuntu:www-data(ubuntu is my user, www-data is the Nginx user), and rerun composer install. I also made sure the ./storagepermissions were recursively set to 775, and change the owner of my entire Laravel project to ubuntu:www-data.

对我来说麻烦的根源是我将 composer 安装为root,所以我不得不删除./vendor,将~/.composer的所有者和组更改ubuntu:www-data(ubuntu 是我的用户,www-data 是Nginx 用户),然后重新运行composer install。我还确保将./storage权限递归设置为 775,并将我的整个 Laravel 项目的所有者更改为ubuntu:www-data

Some stuff will definitely be different if you're on Windows, but hope this helps!

如果您使用的是 Windows,有些东西肯定会有所不同,但希望这会有所帮助!

回答by shobhit verma

It is a permission error actually. But if you try to run directly from your localhost server, it will work.

实际上是权限错误。但是,如果您尝试直接从本地主机服务器运行,它将起作用。

On windows 10 PHP Server will not be able to access PHP Pear extension that is why it is showing this error.

在 Windows 10 上 PHP Server 将无法访问 PHP Pear 扩展,这就是它显示此错误的原因。

If you are running XAMPP. you have to go to your apache localhost with http://localhost/laravel-folder/public.

如果您正在运行 XAMPP。您必须使用http://localhost/laravel-folder/public访问您的 apache localhost 。