# Read a local JSON file

**URL:** <https://discourse.slimframework.com/t/read-a-local-json-file/1354>\
**Category:** Questions\
**Created:** [March 31, 2017, 3:00pm UTC](https://discourse.slimframework.com/t/read-a-local-json-file/1354 "2017-03-31T15:00:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://discourse.slimframework.com/u/jcarlos)\
**Post date:** [March 31, 2017, 3:00pm UTC](https://discourse.slimframework.com/t/read-a-local-json-file/1354/1 "2017-03-31T15:00:29Z")

</div>

Hi.

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](https://github.com/slimphp/Slim/issues/2194)

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [March 31, 2017, 3:38pm UTC](https://discourse.slimframework.com/t/read-a-local-json-file/1354/2 "2017-03-31T15:38:04Z")

</div>

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 `require` or `include` I’ll often use the ` __DIR__ ` shortcut.

```php
$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.

---

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://discourse.slimframework.com/u/jcarlos)\
**Post date:** [March 31, 2017, 3:44pm UTC](https://discourse.slimframework.com/t/read-a-local-json-file/1354/3 "2017-03-31T15:44:50Z")

</div>

`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 `http://localhost:8080/employees.json`

**Edit:**  
I got it using `$str = file_get_contents( __DIR__. '/../public/employees.json');`
