为什么在访问 Laravel 应用程序时“没有这样的文件或目录... autoload.php”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18407208/
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
Why "no such file or directory ... autoload.php" when accessing Laravel app?
提问by Darwing
I am a newbie to Laravel, have been trying to install Laravel, wasted three hours unfortunately didn't work. When I access through public directory, I get these errors:
我是 Laravel 的新手,一直在尝试安装 Laravel,可惜浪费了三个小时没有奏效。当我通过公共目录访问时,出现以下错误:
Warning: require(C:\wamp\www\laravel\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in C:\wamp\www\laravel\bootstrap\autoload.php on line 17 Call Stack
警告:require(C:\wamp\www\laravel\bootstrap/../vendor/autoload.php): 无法打开流:C:\wamp\www\laravel\bootstrap\autoload.php 中没有这样的文件或目录第 17 行调用堆栈
And the following:
以及以下内容:
Fatal error: require(): Failed opening required 'C:\wamp\www\laravel\bootstrap/../vendor/autoload.php' (include_path='.;C:\php\pear') in C
致命错误:require(): 在 C 中打开所需的 'C:\wamp\www\laravel\bootstrap/../vendor/autoload.php' (include_path='.;C:\php\pear') 失败
回答by Darwing
Did you install Laravel's dependencies? When you unzip the framework in your work environment (i.g. htdocs) you must install the necesary dependencies with the command php composer.phar install
(assuming you have installed composer and git). When that is done, you will be able to see the home page of the framework.
您是否安装了 Laravel 的依赖项?当您在您的工作环境(ig htdocs)中解压框架时,您必须使用命令安装必要的依赖项php composer.phar install
(假设您已经安装了 composer 和 git)。完成后,您将能够看到框架的主页。
回答by Anil Singh
I had same problem on Windows(Also works for Mac).
我在 Windows 上遇到了同样的问题(也适用于 Mac)。
Solution:
解决方案:
- Install composer
- Open cmd
- Navigate to your laravel application root
- Run
composer install
command in cmd
- 安装作曲家
- 打开cmd
- 导航到您的 Laravel 应用程序根目录
composer install
在cmd中运行命令
Done!
完毕!
回答by Rasel Ahmed
This message occurs for Laravel's dependencies.
If never run composer install
in your project then run this command on the terminal.
Else run composer update --no-scripts
. All Laravel dependencies will download.
Laravel 的依赖项会出现此消息。如果从未composer install
在您的项目中运行,则在终端上运行此命令。否则运行composer update --no-scripts
。将下载所有 Laravel 依赖项。
回答by Ahmad Baktash Hayeri
To get around this problem, doing a composer self-update
would do the trick. Moreover, as long as the composer
command itself works in your command-line/bash (which means you have it in your PATH) you don't necessarily need to go the actual path where composer.phar
resides in (i.e. c:/ProgramData/Composer/bin or whatsoever).
为了解决这个问题,做一个composer self-update
就可以了。此外,只要composer
命令本身在您的命令行/bash 中工作(这意味着您在 PATH 中拥有它),您不一定需要去composer.phar
驻留的实际路径(即 c:/ProgramData/Composer/bin或任何)。
回答by Patrick Batenburg
Your Laravel installer is giving an error.
您的 Laravel 安装程序出现错误。
Do composer global require "laravel/installer"
做 composer global require "laravel/installer"
Then the new Laravel installer will be installed. Your new Laravel will not return an error then.
然后将安装新的 Laravel 安装程序。你的新 Laravel 将不会返回错误。
回答by BENMADANI Fay?al
if you are migrating the project,try to delete composer.lock
and then composer install
.this worked for me!
如果您正在迁移项目,请尝试删除composer.lock
然后。这composer install
对我有用!
回答by Wei
This error indicates it can not find "autoload.php" under the vendor folder.
此错误表示在供应商文件夹下找不到“autoload.php”。
Make sure the vendor folder is generated by running the "composer install" command and the autoload.php file also created.
确保通过运行“composer install”命令和 autoload.php 文件生成了 vendor 文件夹。
回答by Syed Mobarak
In Windows CMD I faced similar issue and fixed with this command below. After clone a laravel project from my git repository, there was no /vendor directory (logically). This below command creates fresh new /vendor directory and appropriate autoload.php file inside it.
在 Windows CMD 中,我遇到了类似的问题,并使用下面的命令进行了修复。从我的 git 存储库克隆 laravel 项目后,没有 /vendor 目录(逻辑上)。下面的命令会在其中创建全新的 /vendor 目录和相应的 autoload.php 文件。
composer update --no-scripts
回答by Osei-Bonsu Christian
Just make your storage folder writable. This can be found in your app directory
只需使您的存储文件夹可写。这可以在您的应用程序目录中找到
In your terminal use this command
在您的终端中使用此命令
chmod +w <directory> or chmod a+w <directory>
Make sure you navigate to the directory containing the directory you want to make writable or you point to that path.
确保导航到包含要使其可写的目录的目录,或者指向该路径。