Route::get('marquee', function(){
echo File::get('\storage\app\marquee.json');
});
I have a json file place inside storage/app
My question is how can I read this content from controller or route?
Using Storage facade:
Storage::disk('local')->get('marquee.json');
The old way, using File facade (deprecated for Laravel 7):
File::get(storage_path('app/marquee.json'));
You can go with the absolute path
\Illuminate\Support\Facades\File::get(base_path() . '/storage/app/marquee.json');
base_path() in-front of the file path as above. FYI.From external source use Http requests, documentation here, eg:
$response = Http::get('http://test.com');
File::get('marquee.json')?File::get(asset('storage/app/marquee.json'));/storage/app/implies that it's the the filesystem root.