I am using Slimframework for the first time.
And I want to use a JSON file as my database.
I want to read the JSON file and create an API over that.
But I can’t get the content using file_get_contents.
Please give me some ideas: https://github.com/slimphp/Slim/issues/2194
The end of the error message
No such file or directory in [...] should tell you where it is currently looking for that file. From there you should be able to work out if you need to tell PHP to go up or down a directory from where it is looking.
When dealing with local files like using
include I’ll often use the
$str = file_get_contents(__DIR__ . 'employees.json');
You could also echo out
__DIR__ and work from there where your file is relative to that path.
No such file or directory in C:\wamp\www\php\employees-app\src\routes.php on line 13 just specify the line of code where the error occurs =(
Thank you for your help.
There is no a variable like the
__DIR__ but pointing to the public folder or the full path?
I want to access to
I got it using
$str = file_get_contents(__DIR__ . '/../public/employees.json');