Building a RESTful API

Almost all permutations of a RESTful application have one thing in common: a User entity. So, for our example project, we will create a tiny REST application to create, read, update, and delete users, (also known as CRUD).

You can see this project fully completed at my GitLab repository. There are two branches there because I decided to divide this project into two parts: the first branch, master, contains only basic functionality without any specific PhalconPHP features, while the second one, logging-and-cache, contains Phalcon’s logging and caching functionality. You can compare them and see how easy it is to implement such functions in Phalcon.

Installation

I’m not going to go over installation: You may use any database, any operating system, and any web server that you want. It is described well in the official install documentation, so just follow the instructions depending on your operating system.

Web server installation notes are also available in the official Phalcon documentation.

Note that your PHP version should not be less than 5.6.

I use Ubuntu 16.10, PostgreSQL 9.5.6, Nginx 1.10.0, PHP 7, and Phalcon 3.0. I’ve included an Nginx config sample and a PostgreSQL dump file in the project, so feel free to use them. If you prefer another configuration, it won’t be difficult to change it.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *