I am creating a rest api using yii framework so the basic output format would be json….
I want all actions in a controller to have header content-type as ‘application-json’.
I tried to put it in beforeFilter function in the controller but it didn’t work.
Can any one help me out…
Create an
init()function in the Controller class (protected/components/Controller.php). This will be called when any Controller/Action is called. Eg:The
$this->idreturns the controller id. You must obviously replace the 1 in the code above with the relevant controller id for the controller you want the function to take place with