Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to store JSON file inside Laravel folder structure

I want to store some data in a JSON file. The data will be decoded using json_decode function and passed to view.

File example:

{
  "rooms": [
    {
      "name": "Aula Magna 1",
      "camera_url": "camera url",
      "audio_card": "audio card"
    },
    {
      "name": "Aula Magna 2",
      "camera_url": "camera url",
      "audio_card": "audio card"
    },
    {
       "name": "Aula Minor",
       "camera_url": "camera url",
       "audio_card": "audio card"
    }] 
}

I want to convert this file into an array so I can access it inside a view like so

@foreach( $rooms as $room)
   ....
@endforeach

Where inside Laravel folder structure should be data file like this stored?

like image 640
martin49 Avatar asked Sep 16 '25 21:09

martin49


1 Answers

You should put your file inside the storage folder as it is a non-public directory.

You can also place it in resources folder, but it is not the best place, as this folder is used for source files and is usually stored in source code repository (e.g. git).

like image 183
Rahul Avatar answered Sep 18 '25 14:09

Rahul