简体   繁体   English

致命错误:找不到类“Illuminate\\Foundation\\Application”

[英]Fatal error: Class 'Illuminate\Foundation\Application' not found

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 Laravel's Local Development Server no such problem arises only if I use wamp server编辑:当我使用创建模型的php artisan make:model Page命令时就会出现这个问题,但是当我访问该站点时会显示上述错误 如果使用 Laravel 的本地开发服务器,则只有当我使用 Laravel 的本地开发服务器时才会出现此类问题使用 wamp 服务器

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.我能够使用--no-scripts标志来阻止 artisan 在它被包含之前执行。 Once my dependencies were in place, everything worked as expected.一旦我的依赖到位,一切都按预期工作。

composer update --no-scripts

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.以防万一我在 2 周内再次绊倒这个错误......我的情况:通过 git 签出现有项目并通过 composer 拉入所有依赖项。 Came down to the same error listed within the title of this post.归结为本文标题中列出的相同错误。

Solution:解决方案:

composer dump-autoload
composer install --no-scripts

make sure everything works now as expected (no errors!)确保现在一切都按预期工作(没有错误!)

composer update

Something is clearly corrupt in your Laravel setup and it is very hard to track without more info about your environment.您的 Laravel 设置中的某些内容显然已损坏,如果没有有关您的环境的更多信息,则很难跟踪。 Usually these 2 commands help you resolve such issues通常这两个命令可以帮助您解决此类问题

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 分钟左右。

In my case composer was not installed in that directory.在我的情况下,composer 没有安装在那个目录中。 So I run所以我跑

composer install

then error resolved.然后错误解决了。

or you can try或者你可以试试

composer update --no-scripts
cd bootstrap/cache/->rm -rf *.php
composer dump-autoload

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更新,我想在laravel分支上工作然后我结帐并做composer更新所以我得到了错误,

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 然后它被修复。

I had accidentally commented out:我不小心注释掉了:

require __DIR__.'/../bootstrap/autoload.php';

in /public/index.php在/public/index.php

When pasting in some debugging statements.粘贴一些调试语句时。

Easy as this, that worked for my project就这么简单,这对我的项目有用

  • Delete /vendo r folder删除/vendo r 文件夹
  • and execute composer install并执行composer install
  • then run project php artisan serve然后运行项目php artisan serve

对于最新的 Laravel 版本,还要检查您的版本,因为我也遇到了这个错误,但是在更新最新的 php 版本后,我摆脱了这个错误。

please test below solution:请测试以下解决方案:

  • first open command prompt cmd ==> window+r and go to the location where laravel installed.首先打开命令提示符cmd ==> window+r并转到安装 Laravel 的位置。

  • try composer require laravel/laravel尝试composer require laravel/laravel

我无法想象其他任何人都像我一样愚蠢,但以防万一......在解决合并冲突时,我不小心从我的 composer.json 中删除了 "laravel/framework": "^5.6"。

i was having same problem with this error.我对这个错误有同样的问题。 It turn out my Kenel.php is having a wrong syntax when i try to comply with wrong php8 syntax当我尝试遵守错误的 php8 语法时,结果我的 Kenel.php 有错误的语法

The line should be该行应该是

protected $commands = [
    //
];

instead of代替

protected array $commands = [
        //
];

composer install运行composer require laravel/framework然后php artisan key:generate在kali linux中为我php artisan key:generate它的工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么致命错误:未捕获错误:找不到类“Illuminate\\Foundation\\Application” - Why Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found PHP 致命错误:未捕获错误:Class 在 /home/khadija/InstProject/bootstrap/app.php:14 中找不到“Illuminate\Foundation\Application” - PHP Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found in /home/khadija/InstProject/bootstrap/app.php:14 Laravel 未找到“Illuminate\\Foundation\\Application”类 - Class 'Illuminate\Foundation\Application' not found Laravel php 工匠不工作并显示致命错误未捕获错误:Class“Illuminate\Foundation\Application”bootsrap\app.php - php artisan is not working and showing Fatal error Uncaught Error: Class "Illuminate\Foundation\Application" bootsrap\app.php /bootstrap/start.php中的Laravel错误:\ Illuminate \ Foundation \ Application not found - Laravel error in /bootstrap/start.php: \Illuminate\Foundation\Application not found 在 laravel 新版本中找不到类“Illuminate\Foundation\Auth\Student”错误 - Class "Illuminate\Foundation\Auth\Student" not found error in laravel new version 获取:找不到错误类“Illuminate\\Foundation\\Auth\\users” - Getting: Error Class 'Illuminate\Foundation\Auth\users' not found 致命错误:找不到类 'Illuminate\\Database\\Capsule\\Manager' - Fatal error: Class 'Illuminate\Database\Capsule\Manager' not found PHP致命错误:找不到类“ Illuminate \\ Support \\ ServiceProvider” - PHP Fatal error: Class 'Illuminate\Support\ServiceProvider' not found Model class 在 Illuminate\Foundation\Auth\Vendor 中找不到 - Model class not found in Illuminate\Foundation\Auth\Vendor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM