Search code examples
jsonlaravelcontrollerload

How to load json file into Laravel Controller?


I have a JSON file that I would like to load into a controller in Laravel so that I can use the data into my application.

The files path is /storage/app/calendar_Ids.json.

What is the correct way to go about doing this?


Solution

  • Here, this should help you get sorted.

    use Storage;
    
    $json = Storage::disk('local')->get('calendar_Ids.json');
    $json = json_decode($json, true);