Using phpdocx with Yii

  • Sep 26, 2013


This post is outdated. For up date information about using phpdocx with Yii please refer to the Integrate phpdocx with Yii 2.

To use phpdocx within the Yii framework, you just need to follow these steps in your controller:


// unregister Yii autoloader
spl_autoload_unregister(array('YiiBase', 'autoload'));
// import the library
// include the required libraries
require_once 'lib/log4php/Logger.php';
require_once 'classes/';

// create the new document
$docx = new CreateDocx();
$text = 'New text.';

$paramsText = array(
'b' => 'on',
'font' => 'Arial'

$docx->addText($text, $paramsText);

// register Yii autoloader again
spl_autoload_register(array('YiiBase', 'autoload'));

To set the path where to save the documents we recommend you
use a config param in protected/config/main.php:



// add this parameter to set the path where to save the document:

$docx->createDocx(Yii::app()->params['uploadPath']. '/' .'example_text');