Answer the question
In order to leave comments, you need to log in
What are the ways to store infrequently changing data of different types in Laravel?
I am developing a website in Laravel.
There are various data that are used in many places. For example, a company phone number, or some kind of array.
Occasionally, this data will need to be changed.
Where is all this stored?
What is considered the best way in Laravel?
Answer the question
In order to leave comments, you need to log in
If it's rare it's once a year or there is someone who can do it:
If more often or it is a pity to pay someone who can do it:
+ and minimal binding for editing
You won’t believe it)
In the DB) array, of course, it’s better not to hard code, but to collect from the same database.
But if it’s too tight, go to redis
IMHO:
- some technical variables, or those that the customer did not want to edit simply and conveniently (well, he changes them once a year - you can ask a programmer) - as JhaoDa said - in .env and configs.
- non-technical variables, or those that the customer wished to edit simply and conveniently - in hocon/toml/yaml (or similar languages) files. All of them have a syntax that the customer can handle, as well as ready-made parsers. Absolutely utopia - automatically mapit them into the objects of the development language, with the help of some annotations or other instructions.
As for the company's phone or some array.
You create a company.php file in the config folder
and write it there
/*
|--------------------------------------------------------------------------
| Телефон
|--------------------------------------------------------------------------
*/
'phone' => 5555555,
/*
|--------------------------------------------------------------------------
| массив данных
|--------------------------------------------------------------------------
*/
'array' => [
'title' => value,
'title2' => value2,
],
$phone = config('company.phone');
$array = config('company.array');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question