I have the Laravel Administrator Plugin and I set up a setting administrator page that is located in:
app/config/administrator/settings/site.php
The application can store the data, but when i try to get some data in one of my controllers like this:
Config::get('administrator.settings.site')
I can get a returned value... Always null or array 0.
How I can get those configuration values?
How to Access Config Value in Laravel? Hello Dev’s, Today now in this Example,I will show you how to get value from config file in laravel application . We can simply get config value in our laravel application. Here we will use config () method in controller then get config file value in our controller.
To install Laravel in a subfolder let’s walk through a typical server setup to demonstrate it. Typically the path to the web root is something like this, but it can vary depending on your host: With this path, the “html” folder is the web root, and your domain will typically point here.
Not only this but the .git files as well that can expose other sensitive data. If you have Laravel installed in a subfolder, please check that none of the dot files or the other directories are accessible through the browser, and if they are you can hide them by moving the out of the web root, or using .htaccess on Apache, or Nginx config.
Laravel's default .env file contains some common configuration values that may differ based on whether your application is running locally or on a production web server. These values are then retrieved from various Laravel configuration files within the config directory using Laravel's env function.
You can use a file path rather than dot notation for file paths:
Config::get('administrator/settings/site.variable_name');
Dot notation is used to get variables inside the config array within a file, rather than to denote file paths.
Therefore you can use Config::get('administrator/settings/site.variable_name');
to get $variable_name from administrator/settings/site.php
, or ENV_DIR_NAME/administrator/settings/site.php
depending on your environment.
Directories within in app/config
are read as environments. For example app/development/database.php
will work with Config::get('database.whatever')
when you're in your "development" environment while app/production/database.php
will be read with Config::get('database.whatever')
when you're in the "production" environment.
Laravel falls back to the config/config/*.php
file when no environment-specific file is present.
I believe that admin package has a config file in app/config/packages/frozennode/administrator/administrator.php
which the package would like you to use for it's settings. That should be available using this convention: Config::get('package::file.option');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With