Install

easy as one two yii


peml

YiiML relies on the peml library being available on your server. For instructions on installing peml, please see the peml website and get the standalone version working.


Yii Component

Now peml is available, download the YiiML component package. This contains two directories. The peml directory contains the YiiCL extension to peml, and should be appropriately placed in the peml library on your server.

The yii directory contains the component, and should be placed inside the components directory of your yii application. Once there, just add the renderer configuration to your yii configuration file like so:

protected/config/main.php

'components'=>array(
  ...
  'viewRenderer'=>array(
    'class'=>'YiiML',
  ),
  ...
),

As of this distribution, the viewRenderer acts as an intercept, loading .yiiml view files if they are available, but otherwise falling back to the normal .php view file and doing no specific processing.


Controller modification

While this allows a testing and parallel development of php and yiiml views, it will error if there is no

view file for an action, even if a .yiiml is available. In order to solve this, you need to override
the resolveViewFile function in the Controller class. In a standard Yii setup this has already been subclassed and extended from by your project. So it should be a simple case of opening the Controller.php in your components, and adding this function:

controller.php

public function resolveViewFile($viewName,$viewPath,$basePath)
{
  if(empty($viewName))
    return false;
  if(($renderer=Yii::app()->getViewRenderer())!==null)
    $extension=$renderer->fileExtension;
  else
    $extension='.php';
  if($viewName[0]==='/')
    $viewFile=$basePath.$viewName.$extension;
  else if(strpos($viewName,'.'))
    $viewFile=Yii::getPathOfAlias($viewName).$extension;
  else
    $viewFile=$viewPath.DIRECTORY_SEPARATOR.$viewName.$extension;
  return Yii::app()->findLocalizedFile($viewFile);
}