title: Creating REST API
body: <p>I'm creating my first API. 
  I need to create, modify, get and delete two kinds of things: users, dogs (for example). Dogs depends on users. So:</p>
  
  <ul>
  <li>GET "/users/12/dogs" (get list of dogs of user #12) </li>
  <li>GET "/users/12/dogs/2" (get the dog # 2 of user # 12) </li>
  <li>DELETE "/users/12" (delete user # 12) </li>
  <li>POST "/users/12/dogs" (create new dog for user # 12)</li>
  </ul>
  
  <p>etc..</p>
  
  <p>I dont know what to do on backend. I'm figuring to make REST API on plain PHP (or using Laravel). As I understand - I have to make file (for example api.php) and listen there to requests, do something with db and make a response back to frontend. But if I call "/users/12/dogs" with GET request, how my server should know, that this data for API. The path of API file is "/api.php", but I call "/users/12/dogs", how this request redirects to "api.php"? Or how it should works?</p>
  
  <p>Second question is: how many files of API should I have? Is it good to put all API requests listeners (for both "/users/" and "users/1/dogs/12") in one file,</p>
  
  <p>Of course before asking this question I googled and read some about it. There are many information about four main requests, about URLs, about "easy REST API" frameworks, about REST API realization in common. But nowhere about details of realization.. </p>
  
  <p>Answer my questions, please or give some links to good detailed description of REST API realization on PHP.</p>