Book Image

Learning Phalcon PHP

By : Calin Rada, Ioan C Rada
Book Image

Learning Phalcon PHP

By: Calin Rada, Ioan C Rada

Overview of this book

Table of Contents (17 chapters)
Learning Phalcon PHP
About the Author
About the Reviewers

Writing a fully functional REST module with Phalcon PHP

Before starting, I recommend that you use a RESTful client that will help you test things faster. Personally, I prefer DHC (it's a Chrome extension), which can be found at

We are going to develop the CRUD operations for Articles, Categories, Hashtags and Users. Let's start with Articles.


We have already created the controller, so by executing a GET method on https://learning-phalcon.localhost/api/v1/articles, you should get a response. Let's implement the article manager for the articles listing so that we can retrieve real data.

First of all, we will make some changes to the Article model and overwrite the toArray() method. Open modules/Core/Models/Article.php and append the following code:

public function getTranslations($arguments = null) {
  return $this->getRelated('translations', $arguments);

public function getCategories...