Best Practise For Big Rest Apis

I read the Wiki post about creating a REST service with Yii. (http://www.yiiframew…ate-a-rest-api/) and apart from that this solution is significantly more complex than creating a SOAP service I am woundering how to create a big webservice that is using a lot of models.

Following the example the code from the Wiki post, the REST API controller is blowing up more and more (what probably is not improving the performance and memory usage behaviour of PHP)

Does somebody have a charmant solution for building a "very big" REST API in Yii?

My current solution is to make controllers with the 5 functions for every model and reference them in the ApiController… But somehow this solution seems to be a little “dirty” so i am yelling for professional help… ;)

Has somebody a nice idea?

Example :




	public function loadCtrl( $ModelName )

	{

		switch( strtolower( $ModelName ) )

		{

 			case 'model1' :

 				return new ApiPartialModel1();

				break;

				

 			default:

 				break;

		}

		

		// Model not implemented error

		$this->_sendResponse(501, sprintf(

				'Error: Mode <b>list</b> is not implemented for model <b>%s</b>',

				$_GET['model']) );

		Yii::app()->end();				

		

	}


	public function actionView()

	{   	

		$Ctl = $this->loadCtrl( $_GET['model']);

		

		$Res = $Ctl->actionView();

		

 		

		// Did we get some results?

		if(empty($Res)) {

			// No

			$this->_sendResponse(200,

					sprintf('No items where found for model <b>%s</b>', $_GET['model']) );

		} else {

			// Prepare response

			$rows = array();

			foreach($Res as $model)

				$rows[] = $model->attributes;

         	

			// Send the response

			$this->_sendResponse(200, CJSON::encode($rows));

		}		

	}