Laravel 5 错误类“应用程序”中未找到

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32879678/
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:25:47  来源:igfitidea点击:

Laravel 5 error Class 'App' not found in

phplaravel

提问by Nean

I am currently learning laravel 5 and wanted to implement the repository concept. as I understand. I should put an ioc.php and the config folder and put my bindings their

我目前正在学习 laravel 5 并希望实现存储库概念。我认为。我应该放一个 ioc.php 和 config 文件夹并将我的绑定放在他们的

Here is my config/ioc.php

这是我的 config/ioc.php

<?php 
 App::bind('QuestionRepository', 'IQuestionRepository');
 App::bind('AnswerRepository', 'IAnswerRepository');

I get an error Class 'App' not found in

我收到一个错误 Class 'App' not found in

回答by Basit

try prefixing App with \ like \App

尝试在 App 前加上 \ like \App

回答by ShivarajRH

For my case in lumen 5.4, undefined 'App' class issue solved by facade definition:

对于我在 lumen 5.4 中的情况,外观定义解决了未定义的“App”类问题:

use Illuminate\Support\Facades\App;

回答by Maarten00

In my case, my .env file contained a value with spaces after checking out a new project.

就我而言,我的 .env 文件在签出新项目后包含一个带空格的值。

Running php artisan optimizefor the first time would throw this error because my Exception handler was trying to use the '\App' global alias for the App facade. Commenting that code showed the real error;

php artisan optimize第一次运行会抛出这个错误,因为我的异常处理程序试图为 App 外观使用 '\App' 全局别名。注释该代码显示了真正的错误;

"Dotenv values containing spaces must be surrounded by quotes."

“包含空格的 Dotenv 值必须用引号括起来。”