I launch the server from the index.php file on localhost. In this file, using the Slim framework, I try to read the data and output it. The question is how to make it work? The code and error sent by the server is as follows:
<?php use \Psr\Http\Message\ServerRequestInterface as Request; use \Psr\Http\Message\ResponseInterface as Response; require 'vendor/autoload.php'; $app = new \Slim\App(); $app->get('/1/', function(Request $reg, Response $res, $args = []){ $t = json_decode(file_get_contents('home/web/t.json'), true); return $res->write->withStatus(400)->$t["t"][0]["id"]; }); $app->run(); The terminal gives the following error:
f[Sun Aug 19 07:51:03 2018] PHP Warning: file_get_contents(home/web/t.json): failed to open stream: No such file or directory in /home/web/index.php on line 17
file_get_contents(__DIR__ . '/t.json')- Dmitriy Simushev