【问题标题】:Yii - how to include phpdocx files?Yii - 如何包含 phpdocx 文件?
【发布时间】:2013-09-16 15:00:04
【问题描述】:

我正在尝试在我的 Yii 项目中包含 phpdocx 文件。在一个独立的 php 脚本上,我所要做的就是

require_once 'phpdocx/classes/CreateDocx.inc';

不知道如何使用 Yii。我将文件夹放在 protected/components/thirdparty/phpdocx 下。并在 config/main.php 中添加了上面的行(路径正确),但 Yii 找不到其余的 .inc 文件。

如何包含这些内容?

【问题讨论】:

    标签: yii yii-components phpdocx


    【解决方案1】:

    试试这个:

    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');
    

    【讨论】:

    • 尝试替换 spl_autoload_register(array('YiiBase', 'autoload'));与 Docx 合作结束
    • @user187809,什么类无法加载?
    【解决方案2】:

    你需要使用命名空间版本的 Phpdocx,然后在 composer.json 中加载库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-01
      • 1970-01-01
      • 2014-06-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多