[英]Why is Laravel throwing an error like “Call to a member function make() on null in…”?
I have defined constant.php file inside app folder like app/constant.php
. 我已经在app文件夹中定义了constant.php文件,例如app/constant.php
。 And I have defined my upload url like: 而且我已经定义了我的上传网址,例如:
define('DIR_UPLOADS', url('/').'/uploads/');`
but it throws the following error: 但它引发以下错误:
Call to a member function make() on null in C:\\xampp\\htdocs\\rabble\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\helpers.php on line 53 在第53行的C:\\ xampp \\ htdocs \\ rabble \\ vendor \\ laravel \\ framework \\ src \\ Illuminate \\ Foundation \\ helpers.php中的 null上调用成员函数make()
I have also created a new folder named uploads and I'm using Laravel 5.1
. 我还创建了一个名为uploads的新文件夹,并且正在使用Laravel 5.1
。 I have also tried composer update
and composer dump-auto
. 我也尝试过composer update
和composer dump-auto
。
What is causing this error and how do I fix it? 是什么导致此错误,我该如何解决?
When config files are loaded the container is not yet fully initialized. 加载配置文件后,容器尚未完全初始化。 When you call url() helper, it's trying to get UrlGenerator service from the container, but the container instance does not exist yet. 当您调用url()帮助程序时,它正在尝试从容器中获取UrlGenerator服务,但是该容器实例尚不存在。
You should also use Config facade to store/retrieve global settings instead of defining PHP constants. 您还应该使用Config Facade来存储/检索全局设置,而不是定义PHP常量。
What do you want to use this constant for? 您想将此常量用于什么? Please elaborate and I'll find a better place to put it. 请详细说明,我会找到一个更好的地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.