我想在我的Yii項目中包含phpdocx文件。在一個獨立的PHP腳本,我所要做的就是Yii - 如何包含phpdocx文件?
require_once 'phpdocx/classes/CreateDocx.inc';
不知道如何做到這一點與Yii。我把文件夾放在protected/components/thirdparty/phpdocx下。並在config/main.php中添加上面的行(使用正確的路徑),但是Yii找不到.inc文件的其餘部分。
如何包含這些?
我想在我的Yii項目中包含phpdocx文件。在一個獨立的PHP腳本,我所要做的就是Yii - 如何包含phpdocx文件?
require_once 'phpdocx/classes/CreateDocx.inc';
不知道如何做到這一點與Yii。我把文件夾放在protected/components/thirdparty/phpdocx下。並在config/main.php中添加上面的行(使用正確的路徑),但是Yii找不到.inc文件的其餘部分。
如何包含這些?
試試這個:
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');
您需要使用Phpdocx的命名空間的版本,然後只需加載庫composer.json。
同樣的錯誤:(它不能加載類 – user187809
嘗試替換spl_autoload_register(array('YiiBase','autoload'));到Docx – Sergey
@ user187809工作結束,以及哪些類無法加載? – Sergey