laravel php artisan serve 找不到 autoload.php
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50632310/
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
php artisan serve can't find the autoload.php
提问by Charbel Sarkis
SOLUTION:laravel new project-name
was actually giving me an error that i overlooked. I had the wrong version of php. It requiresphpv7.1.3 or higher. If you don't have it it doesn't work.
解决方案:laravel new project-name
实际上给了我一个我忽略的错误。我有错误的 php 版本。它需要phpv7.1.3 或更高版本。如果你没有它,它就不起作用。
Ran into one other problem:
遇到另一个问题:
- i had a system environment variable that is pointing to an old version of php
- Also laravel requires openssl extension and mbstring to turned on. UNCOMMENTED from php.ini
- 我有一个系统环境变量指向旧版本的 php
- 此外,laravel 需要打开 openssl 扩展和 mbstring。来自 php.ini 的未注释
FOR NEWCOMERS: if you have just downloaded php and unzipped the file. It contains a file called
对于新人:如果您刚刚下载了 php 并解压缩了文件。它包含一个名为
install.txt
安装文件
that you HAVEto read. It explains everything.
你HAVE阅读。它解释了一切。
I ran laravel new blog
from their getting started page. When I tried to run php artisan serve
, I got the following error:
我laravel new blog
从他们的入门页面跑了。当我尝试运行时 php artisan serve
,出现以下错误:
Warning: require(C:\Projects\laravel-projects\blog/vendor/autoload.php): failed to open stream: No such file or directory in C:\Projects\laravel-projects\blog\artisan on line 18
警告:require(C:\Projects\laravel-projects\blog/vendor/autoload.php): 无法打开流:C:\Projects\laravel-projects\blog\artisan 中第 18 行没有这样的文件或目录
The artisan file is pointing to
工匠文件指向
require __DIR__.'/vendor/autoload.php';
this directory does not exist. Even if I point it to the correct directory, it still wouldn't work because I don't have read permissions for that folder (so it gets denied).
该目录不存在。即使我将它指向正确的目录,它仍然无法工作,因为我没有该文件夹的读取权限(因此它被拒绝)。
What's going on, and how can I fix this?
这是怎么回事,我该如何解决?
EDIT: changed the url from the mentioned above to:
编辑:将上述网址更改为:
C:\Users\sarkis\AppData\Roaming\Composer\vendor\autoload.php
C:\Users\sarkis\AppData\Roaming\Composer\vendor\autoload.php
This worked perfectly for some reason. And NOW. A NEW ERRORHAS APPEARED.
由于某种原因,这非常有效。现在。出现了新错误。
Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found in C:\Projects\laravel-projects\blog\bootstrap\app.php:14 Stack trace:#0 C:\Projects\laravel-projects\blog\artisan(21): require_once() #1 {main} thrown in C:\Projects\laravel-projects\blog\bootstrap\app.php on line 14
致命错误:未捕获的错误:在 C:\Projects\laravel-projects\blog\bootstrap\app.php:14 中找不到类 'Illuminate\Foundation\Application' 堆栈跟踪:#0 C:\Projects\laravel-projects\blog \artisan(21): require_once() #1 {main} 在 C:\Projects\laravel-projects\blog\bootstrap\app.php 第 14 行抛出
found that i don't have the proper version of php required.
发现我没有所需的正确版本的 php。
回答by NARGIS PARWEEN
- First Install Composer: composer install.
- Then run a command in CMD prompt: composer dump-autoload.
- 首先安装 Composer:composer install。
- 然后在 CMD 提示符下运行命令:composer dump-autoload。
回答by Rick Wang
I'm new to Laravel, and I got the same confusion with the command:
我是 Laravel 的新手,我对命令也有同样的困惑:
laravel new blog
There was no vendor folder.
没有供应商文件夹。
But after I tried:
但在我尝试之后:
composer create-project --prefer-dist laravel/laravel blog
I found the vendor folder came up.
我发现供应商文件夹出现了。
Don't know why either.
也不知道为什么。
回答by Ralf Gerald
You could try install via Composer Create-Project
:
您可以尝试通过Composer Create-Project
以下方式安装:
composer create-project --prefer-dist laravel/laravel blog
回答by Nico Bistolfi
Try running composer dump-autoload, after that run a composer install
尝试运行composer dump-autoload,然后运行composer install
If that doesn't work, try the composer update --no-scripts
如果这不起作用,请尝试composer update --no-scripts
回答by Charbel Sarkis
When running laravel new project_name. It outputted the text php 7.1.3 or higher needs to be installed. Current version 5.6 does not match requirements. And it aborts without plainly giving you an error. Be sure to download php version 7.1.3 or higher. Also check if you have environment variables for earlier versions of php and delete those.
运行 laravel 时新建 project_name。它输出文本需要安装 php 7.1.3 或更高版本。当前版本 5.6 不符合要求。它会中止而不会明显地给你一个错误。请务必下载 php 7.1.3 或更高版本。还要检查您是否有早期版本的 php 的环境变量并删除它们。
note: be sure to read install.txt from the php download
注意:一定要从 php 下载中读取 install.txt
回答by chohan
Check all your permissions to following folders and give 0777 permissions
检查您对以下文件夹的所有权限并授予 0777 权限
storage 0777
vendor 0777
bootstrap/cache 0777
And then run again
然后再次运行
php artisan serve