background preloader

Cutiso

Facebook Twitter

Unit Testing

ApiEngine - Great apps start with great API's. How-To: Create a REST API. This article will explain how to create a REST API with the Yii framework.

How-To: Create a REST API

Information about REST ¶ A good introduction about implementing REST service with PHP can be found on Usefull Tools ¶ To fire up a REST request to a Yii application, you can use the Firefox REST Client Addon. If you want to send REST requests via a console, perhaps you might check cUrl. Requirements ¶ We will create an API that allows us to Get all items of a certain modelGet one single model item via its primary key (id)Create a new itemUpdate an existing itemDelete an existing item. In this tutorial, we will use the Yii Blog demo application. The API shall be flexible enough that it can be extended easily to work on more different models, e.g. comments or user data. All requests to the API shall use an authorization. All right, let's get things going! Setting up the URL Manager ¶ When using the API, we would like to have the following URL scheme: ... Create an API controller ¶ Implementing the Actions ¶ Sending the Response ¶ Yii for beginners. Intro (Part 1) ¶ Hi.

Yii for beginners

This is first article with my Yii tutorial. I had to split it into more articles as there's limited length of texts on Wiki. So once you understand basics, you can read next article here: Yii for beginners 2. This tutorial is copy of PDF in my forum: Total fresher in PHP frameworks and Yii, I don't understand tutorials I'm writing this tutorial because when I was beginning with Yii I was totally lost.

This tutorial is meant for beginners who have never worked with any PHP framework or with Yii. 1. I suppose the reader is familiar with PHP and databases (DB). 2. MVC (Model-View-Controller) is a type of application architecture. M = Model = Part that defines relations among data in DB and rules that must be followed when saving data to DB. V = View = Part that is used just to show data to user. C = Controller = Part that processes and changes the data, handles user’s actions, decides, counts, thinks and calls models and views … It simply acts.

Image 1) MVC schema. NetBeans IDE and Yii projects. This page is created to supply short directions and general tips for managing a Yii application in NetBeans IDE. 1.

NetBeans IDE and Yii projects

Code completion ¶ To get context sensitive code completion, follow these steps: Include Yii folder (assuming it is properly placed outside project directory) Open "File > Project properties > PHP Include Path" and add the Yii framework root pathIgnore yiilite.php to avoid doubled/missing documentation Open "Tools > Options > Miscellaneous > Files"Add to the front of "Files Ignored by the IDE" the file "^(yiilite\.php|CVS|SCCS|.... "Restart NetBeansCode completion in view files Add the following PHPDoc statement at the head of the file to use code completion in view files. @var @var $this->getSomeProValue(); $model->author; Usage: Typing suggestions: Ctrl-SpaceShow Function parameters: Ctrl-PComment your own code with PHPDoc style. 2. You can create code templates for commonly used/overridden function in Yii. Download this template set to get started: (version 2). 3. 4.

Yii Testing.