简体   繁体   English

为什么Laravel会引发类似“在null中调用成员函数make()的错误……”的错误?

[英]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 updatecomposer 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.

相关问题 Laravel 调用成员 function getName() on null 错误 - Laravel Call to a member function getName() on null Error Laravel DatabaseMigrations产生错误:在null上调用成员函数call() - Laravel DatabaseMigrations produces error: Call to a member function call() on null Laravel在null上调用成员函数 - Laravel call to member function on null 为什么我不能在 Laravel 上正确映射嵌套查询? “在 null 上调用成员函数 map()”显示为错误 - Why can't I properly map nested query on Laravel? "Call to a member function map() on null" shown as error Laravel 5.5-“在null上调用成员函数sync()”错误 - Laravel 5.5 - “Call to a member function sync() on null” Error laravel 5.7错误:在null上调用成员函数save() - laravel 5.7 Error: Call to a member function save() on null 在Laravel中上传文件时出错:在null上调用成员函数 - Error uploading file in Laravel: Call to a member function on null Laravel 5 查询关系导致“调用成员函数 addEagerConstraints() on null”错误 - Laravel 5 Querying with relations causes "Call to a member function addEagerConstraints() on null" error Laravel 中间件错误 - 在 null 上调用成员函数 isBasic() - Laravel Middleware Error - Call to a member function isBasic() on null 在 null 上调用成员函数 addEagerConstraints() 在 laravel 6 上出现此错误 - Call to a member function addEagerConstraints() on null getting this error on laravel 6
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM