Search code examples
apirestmodel-view-controllerfat-free-framework

How to create a RESTful API using Fat Free Framework


I want to create a simple api using Fat free framework but I am confused where should I put my code. Should I put my code in index.php which can also handling routing for the rest of the files. Can somebody help me about this issue. can you please draw a folder structure for me it would be a great favor for me. I want to return the response in json format like this:

{ "artists":
[{
"id": 1,
  "name": "Chavvy Chavface",
  "soundcloud_user_id": 12345,
  "track": {
    "title": "Super Music"
    "soundcloud_track_id": 12345,
  },
  "zipcode": "60613"
}]
}

Solution

  • You're absolutely free to use any folder structure you like. You can put the whole code in your index.php, which the more your project grows, the more yourfile will becomes unreadable and confusing.

    There's also an official CMS demo: https://github.com/bcosca/fatfree/blob/archive/f3-3.0.6.cms.demo.zip