0

I'm trying to include phpdocx files in my Yii project. On a standalone php script, all I have to do is

require_once 'phpdocx/classes/CreateDocx.inc';

Not sure how to do it with Yii. I put the folder under protected/components/thirdparty/phpdocx. And added the line above (with correct path) in config/main.php, but Yii can't find the rest of the .inc files.

How do I include those?

user187809
  • 706
  • 2
  • 8
  • 23

2 Answers2

0

Try this:

define('PHPDOCX_INCLUDE_PATH', (dirname(Yii::app()->basePath)).'/components/thirdparty/phpdocx');

spl_autoload_unregister(array('YiiBase','autoload'));
require_once PHPDOCX_INCLUDE_PATH.'/classes/AutoLoader.inc';
spl_autoload_register(array('AutoLoader','load'));
spl_autoload_register(array('YiiBase', 'autoload'));

// your code
$docx = new CreateDocx();
$docx->addTemplate('files/mytemplate.docx');
Sergey
  • 5,208
  • 25
  • 36
0

You need to use the namespacing version of Phpdocx, and then just load the library in composer.json.

Dimitri
  • 59
  • 3