Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

FutureWeb's avatar

Return json response from a php file

Hi I have a php file which gets a json count of google + pluses how do I grab the output of this file from the routes file ?

Many thanks in advance

0 likes
3 replies
chrisgeary92's avatar
Level 13

Not 100% sure what you're trying to achieve here, so something like this? Or am I totally not on the right track?

Route::get('/my-route', function() {
    $json = json_decode(file_get_contents('path/to/json/file.php'));
});
1 like
bashy's avatar

Could also go and use Laravel facades :P

File::get('path');
File::getRemote('path');
2 likes

Please or to participate in this conversation.