As we learned in Part 1 of this article, how to load SLIM Framework in our joomla 3.4 project and how to instantiate SLIM framework, directory structure explained in part 1 of this tutorial, in this part we will create index.php file flowing our directory structure.
create index.php in /your_project/api/v1/index.php . and paste bellow code, hey don't get confused by seeing this messy line of code , don't worry i will explain each line.
here we require JsonApiView.php JsonApiMiddleware.php that we have created in /your_project/api/JsonApiMiddleware.php and in /your_project/api/JsonApiView.php. this class we will learn letter, before digging into it lets create route for our API.
The Slim Framework helps you map resource URIs to callback functions for specific HTTP request methods (e.g. GET, POST, PUT, DELETE, OPTIONS or HEAD). A Slim application will invoke the first route that matches the current HTTP requests URI and method.
You can find attachment for demo. This was just a simple example. I hope Ive convinced you to start writing Joomla API with the help of Slim Framework. If you have any query feel free to ask in comments.
The advance feature will be provided in the next part of the series, when well also take a look at one of the token, verification, paginated data for the API and most useful feature of SLIM Framework.