php 致命错误:找不到类“Illuminate\Foundation\Application”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29764368/
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
Fatal error: Class 'Illuminate\Foundation\Application' not found
提问by xenish
I am getting following error when I open my site which is made using laravel 5
当我打开使用 laravel 5 制作的网站时出现以下错误
Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\cms\bootstrap\app.php on line 14
致命错误:在第 14 行的 C:\cms\bootstrap\app.php 中找不到“Illuminate\Foundation\Application”类
I have tried removing vendor folder and composer.lock
file and running composer install it's not working I tried running PHP artisan optimize but it shows error
我尝试删除供应商文件夹和composer.lock
文件并运行 composer install 它不起作用我尝试运行 PHP artisan optimize 但它显示错误
Fatal error: Class'Illuminate\Foundation\Application' not found
致命错误:找不到类“Illuminate\Foundation\Application”
Is there any way to solve this problem?
有没有办法解决这个问题?
Edited:
This problem aroused as soon as I used the php artisan make:model Page
command which did create the model but then the above error gets displayed when I access the site
Also If use the Larvel's Local Development Server no such problem arises only if I use wamp server
编辑:一旦我使用php artisan make:model Page
创建模型的命令就会出现这个问题,但是当我访问该站点时会显示上述错误如果使用 Larvel 的本地开发服务器,则仅当我使用 wamp 服务器时才会出现此类问题
回答by Daniel Mitchell
In my situation, I didn't have the full vendor dependencies in place (composer file was messed up during original install) - so running any artisan commands caused a failure.
在我的情况下,我没有完整的供应商依赖项(在原始安装期间作曲家文件搞砸了) - 所以运行任何 artisan 命令都会导致失败。
I was able to use the --no-scripts
flag to prevent artisan from executing before it was included. Once my dependencies were in place, everything worked as expected.
我能够使用该--no-scripts
标志来防止工匠在它被包含之前执行。一旦我的依赖到位,一切都按预期工作。
composer update --no-scripts
回答by mwallisch
Just in case I trip over this error in 2 weeks again... My case: Checkout an existing project via git and pull in all dependencies via composer. Came down to the same error listed within the title of this post.
以防万一我在 2 周内再次绊倒这个错误......我的情况:通过 git 签出现有项目并通过 composer 拉入所有依赖项。归结为本文标题中列出的相同错误。
Solution:
解决方案:
composer dump-autoload
composer install --no-scripts
make sure everything works now as expected (no errors!)
确保现在一切都按预期工作(没有错误!)
composer update
回答by Margus Pala
Something is clearly corrupt in your Laravel setup and it is very hard to track without more info about your environment. Usually these 2 commands help you resolve such issues
您的 Laravel 设置中的某些内容显然已损坏,如果没有有关您的环境的更多信息,则很难跟踪。通常这两个命令可以帮助您解决此类问题
php artisan clear-compiled
composer dump-autoload
If nothing else helps then I recommend you to install fresh Laravel 5 app and copy your application logic over, it should take around 15 min or so.
如果没有其他帮助,那么我建议您安装新的 Laravel 5 应用程序并复制您的应用程序逻辑,大约需要 15 分钟左右。
回答by Onshop
I had accidentally commented out:
我不小心注释掉了:
require __DIR__.'/../bootstrap/autoload.php';
in /public/index.php
在/public/index.php
When pasting in some debugging statements.
粘贴一些调试语句时。
回答by Frank
I can't imagine that anyone else reading this is a stupid as I was but just in case... I had accidentally removed "laravel/framework": "^5.6" from my composer.json when resolving merge conflicts.
我无法想象其他人会像我一样愚蠢地阅读本文,但以防万一……我在解决合并冲突时不小心从我的 composer.json 中删除了 "laravel/framework": "^5.6"。
回答by Calvin
I just fixed this problem (Different Case with same error),
The answer above I tried may not work because My case were different but produced the same error.
I think my vendor libraries were jumbled,
I get this error by:
1. Pull from remote git, master branch is codeigniter then I do composer update on master branch, I wanted to work on laravel branch then I checkout and do composer update so I get the error,
我刚刚解决了这个问题(具有相同错误的不同案例),
我尝试的上述答案可能不起作用,因为我的案例不同但产生了相同的错误。
我认为我的供应商库混乱,
我通过以下方式收到此错误:
1. 从远程 git 拉取,master 分支是 codeigniter 然后我在 master 分支上进行 composer update,我想在 laravel 分支上工作然后我结帐并进行 composer update 所以我得到错误,
Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\cms\bootstrap\app.php on line 14
致命错误:在第 14 行的 C:\cms\bootstrap\app.php 中找不到“Illuminate\Foundation\Application”类
Solution: I delete the project on local and do a clone again, after that I checkout to my laravel file work's branch and do composer update then it is fixed.
解决方案:我在本地删除项目并再次进行克隆,然后我检出到我的 Laravel 文件工作的分支并进行 composer update 然后它被修复。
回答by ankit kumawat
1.first open command prompt(cmd==>window+r) and go to the location where laravel
installed.
1.首先打开命令提示符(cmd==>window+r),进入laravel
安装的位置。
2.try==>'composer require laravel/laravel'
2.try==>'composer 需要 laravel/laravel'
回答by Ajay Malhotra
For latest laravel version also check your version because I was also facing this error but after update latest php version, I got rid from this error.
对于最新的 Laravel 版本,还要检查您的版本,因为我也遇到了这个错误,但是在更新最新的 php 版本后,我摆脱了这个错误。