Home > OS >  How can I read an array value saved in a data file stored inside Config folder in Laravel
How can I read an array value saved in a data file stored inside Config folder in Laravel

Time:01-16

I need to read special configuration for my app in Laravel 8, all my settings are stored in a single filename naned mydata.php inside folder/config

inside mydata.php

return [
    'setting1' => 99,
];

I have tried to read it using

dd(config('mydata.setting1'));

but always return null, I need to get setting1 value

so, I have cleared all config cached

php artisan config:cache
php artisan config:clear
php artisan cache:clear
composer dumpautoload

but It always returns null

thanks

CodePudding user response:

// config/app.php
<?php

return [
    'key' => 'value',
];

and access like

config('app.key');

this is the standard. Is that your actual code up there? Maybe your config file is referring to an env variable that you have not set correctly? It would be easier to help if you would show us your code

CodePudding user response:

I don`t know what was wrong but after restart and I get the correct value

dd(config('mydata'));
  •  Tags:  
  • Related