Access Custom config file

Published 1 month ago by sanjayacloud

Hello every one,

I have create a custom config file & I am try to access it from my library. But I get error like below.

Use of undefined constant errorreporter - assumed 'errorreporter' in laravel

This "errorreporter" is my custom config file


How are you trying to access it?

Normally you create a file app/config/myconfigfile.php.

And its contents could be


return [
    'my-item' => 'value'

And access it like: config('').

Does this help?


I did like this

if(config('' )){ $result = $this->store($errorData); }

But it's not work.


From where in your app did you do this?

What is the contents of your errorreporter.php file in the config directory?

And what does config('') actually return?


@MThomas have you a got some solution.


@sanjayacloud In my first post I showed you how it works, not sure what more you want?

If you are new to Laravel, you might want to start with some of the videos here on Laracasts. And the Laravel Documentation is also a great resource.


I am use this config in my custom library(app\libraries\ErrorReporter.php). and config file like this "

return[ 'active' => true, 'mailalert' => false ] "

And my ErrorReporter.php library file like below.


Where did you save your config file? Is it in your-app/config/?


Yes. Now its ok. But now i try to mass a value when i call in that config but it's not work. but when I change value in my config file to true it's work. can I know how to pass the value for it when I call that config key.

config file:- return [

'active' => false ]

I need this false value change to true when I call in it my library.


config(['' => false]);




@saravana2906 It's not work. I have get 500 error

Please sign in or create an account to participate in this conversation.