使用phpWord和cakephp3未找到类'Zend \ Stdlib \ StringUtils'

时间:2018-11-21 00:09:50

标签: php cakephp phpword

我正在将Cakephp3与PhpWord应用程序一起使用,在这里我只是读入模板并填写数据库中的值。我在/ vendor中有phpoffice目录。除了目录斜杠,这是完全相同的代码在linux中工作!!!在win10中,当我得到

时它不起作用
 Class 'Zend\Stdlib\StringUtils' not found //this file exists in vendor/zendframework/zend-stdlib
 error is from line  $phpWord->setValue("studentname",$studentname);

我不知道为什么这段代码在win10中失败,但是可以在linux服务器上工作

//in controller
use PHPWord;

...

 $template_filename = $assessmentname;
                $template_destname = "$assessmentname-" . $lesson->id . "-" . $student->id;

                $source = getcwd()."\\doc\\templates\\{$template_filename}.docx";
                $template_destfile = $base_dir."{$template_destname}.docx";

                $phpWord = new \PhpOffice\PhpWord\TemplateProcessor($source);
                $phpWord->setValue("studentname",$studentname);  //error is on this line    

                 debug( $source);
                  debug( $phpWord); 

//带有调试的输出证明phpobject已被拾取

     \src\Controller\TutorsController.php (line 4176)

    'C:\wamp64\www\crm\webroot\doc\templates\Secondary Maths and English Assessment.docx'

    \src\Controller\TutorsController.php (line 4177)

    object(PhpOffice\PhpWord\TemplateProcessor) {
        [protected] zipClass => object(PhpOffice\PhpWord\Shared\ZipArchive) {
            numFiles => (int) 18
            filename => 'C:\Windows\Temp\Php767D.tmp'
            [private] tempDir => null
            [private] zip => object(ZipArchive) {
                status => (int) 9
                statusSys => (int) 0
                numFiles => (int) 18
                filename => 'C:\Windows\Temp\Php767D.tmp'
                comment => ''
            }
            [private] usePclzip => false
        }
        [protected] tempDocumentFilename => 'C:\Windows\Temp\Php767D.tmp'
        [protected] tempDocumentMainPart => '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>




...
I cant embed images but here is the stack trace
Error in: ROOT\vendor\phpoffice\PhpWord\src\PhpWord\TemplateProcessor.php, line 195
( ! ) Xdebug: user triggered in C:\wamp64\www\crm\src\Template\Error\error500.ctp on line 33
Call Stack
#   Time    Memory  Function    Location
1   0.8621  11983648    Cake\Error\BaseErrorHandler->wrapAndHandleException( )  ...\BaseErrorHandler.php:0
2   0.8647  11990088    Cake\Error\BaseErrorHandler->handleException( ) ...\BaseErrorHandler.php:163
3   0.8647  11990088    Cake\Error\ErrorHandler->_displayException( )   ...\BaseErrorHandler.php:179
4   0.8719  12087752    Cake\Error\ExceptionRenderer->render( ) ...\ErrorHandler.php:144
5   0.8762  12293032    Cake\Error\ExceptionRenderer->_outputMessage( ) ...\ExceptionRenderer.php:192
6   0.8928  12541352    Cake\Error\ExceptionRenderer->_outputMessage( ) ...\ExceptionRenderer.php:327
7   0.8928  12541352    Cake\Controller\Controller->render( )   ...\ExceptionRenderer.php:320
8   0.8953  12544904    Cake\View\View->render( )   ...\Controller.php:611
9   0.8976  12545840    Cake\View\View->_render( )  ...\View.php:587
10  0.8980  12546672    Cake\View\View->_evaluate( )    ...\View.php:952
11  0.8994  12577000    include( 'C:\wamp64\www\crm\src\Template\Error\error500.ctp' )  ...\View.php:992
12  0.9033  12594912    xdebug_print_function_stack ( ) ...\error500.ctp:33

0 个答案:

没有答案