Home » Android » web services – Yii Framework and Android Application

web services – Yii Framework and Android Application

Posted by: admin June 15, 2020 Leave a comment


I like to raise some questions regrading Yii framework and Android applications. I am going to build a mobile application in Android platform and implementing Yii framework as server side. I like to know how much Yii framework supports Android platform? Are Yii framework web services fully compatible with Android?

And, if can anyone suggest some tutorial or useful information, that will be very useful to me…

How to&Answers:

Check out this: Yii REST API


You can use JSON / XML to communicate your android application with the php yii framework by building a simple REST API.

In order to do use the REST API this, you need to send HTTP request (Get / Post) from Android application. Then perform your operation based upon the request and send again in JSON formate using php json_encode or XML if you preferred.

You can also perform it using google Gson. it will help you to create JSON from java object.


Refer this: Simple API using Yii

I have done similar recently,

Yii side

you need custom controller sending json array and you can refer Yii REST API

public function actionTest()

    $commands = Command::model()->findAll();
    $cmdlist = array();

    if( $commands != '0'){
        foreach( $commands as $item ) 
            $object = array();
            $object ['cmd'] = $item->command;
            $object ['command'] = $item->getCommandOptions($item->command);
            $object ['number'] = $item->number;
            $object ['id'] = $item->id;
            $cmdlist[] = $object;
        $arr['command'] = $cmdlist;

    header('Content-type: application/json');
    echo json_encode($arr);

android side

You need a neat Async Http client with Json parser. I used android-async-http


I have an Android application that is on the market that I am switching to using the Yii framework. I use the http://www.yiiframework.com/extension/restfullyii/ extension. So far it’s been great. I had a couple of issues with security and other things but overall the tool is what you will need. All you really care about for yii is having a restful API the rest of the logic should really be handled in your Android application. Also as a response type at this point I would only use json. I tried to implement a Android XML framework and decided to pull back because json did everything I needed to and was easy.