Get "PHP 8 in a Nuthshell" (Now comes with PHP 8.3)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

A handy File method to read JSON files in Laravel 10.x

We now have a nice addition to the File facade in Laravel 10.x that lets you read JSON files easily. Essentially, it’s a wrapper around the json_decode() function. So, you can use it to read JSON files like so.

use Illuminate\Support\Facades\File;

$users = File::json('users.json');

It saves you the extra step of using the json_decode() function to read JSON files which you would have to do otherwise.

use Illuminate\Support\Facades\File;

$users = json_decode(File::get('users.json'), true);

I really dig such small and focused methods that makes your code more readable and concise.

Learn the fundamentals of PHP 8 (including 8.1, 8.2, and 8.3), the latest version of PHP, and how to use it today with my new book PHP 8 in a Nutshell. It's a no-fluff and easy-to-digest guide to the latest features and nitty-gritty details of PHP 8. So, if you're looking for a quick and easy way to PHP 8, this is the book for you.

Like this article? Consider leaving a


👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.