marcovtwout / yii-phpexcel

Yii wrapper for PHPExcel
24 stars 11 forks source link

not work #6

Closed des1roer closed 8 years ago

des1roer commented 9 years ago

Fatal error: Class 'COutputProcessor' not found in D:\open\OpenServer\domains\localhost\yii\framework\web\widgets\CContentDecorator.php on line 32

Fatal error: Class 'YiiDebug' not found in D:\open\OpenServer\domains\localhost\mining\protected\extensions\yii-debug-toolbar\views\main.php on line 2

des1roer commented 9 years ago

screenshot_8

marcovtwout commented 9 years ago

Can you post full example code that shows the issue?

bdmtra commented 8 years ago

Have same issue with error: Fatal error: Class 'COutputProcessor' not found in /home/p/pagorbiu/alice-street.club/framework/web/widgets/CContentDecorator.php on line 32 then just copy any example from usage section in manual.

marcovtwout commented 8 years ago

Sorry, without a concrete example I cannot reproduce your issue.

Also, the latest Yii 1.1.17 contains improved support for third party autoloaders: http://www.yiiframework.com/news/93/yii-1-1-17-is-released/ Maybe integrating PHP-excel without this component is now easier?

alekir66 commented 8 years ago

@twopizza @marcovtwout @des1roer: I had same issue, triggered with this code, in a view 'xlsreport.php'. View had no model data related. Only was a little test:

<?php
    Yii::import('ext.phpexcel.XPHPExcel');      
    $objPHPExcel = XPHPExcel::createPHPExcel();

Error was triggered on line with $objPHPExcel:

Fatal error: Class 'COutputProcessor' not found in ......\framework\web\widgets\CContentDecorator.php

Environment: PHP 5.5.9.19, Yii 1.1.17, Apache 2.4.7, Ubuntu 14.04. PHPExcel 1.8.1. https://github.com/PHPOffice/PHPExcel/releases

Probably reason: Class PHPExcel not loaded / PHPExcel autoloader integration with Yii1. See http://www.yiiframework.com/forum/index.php/topic/17396-coutputprocessor-yii-is-looking-for-clas-that-is-not-being-used/ and http://www.yiiframework.com/wiki/101/how-to-use-phpexcel-external-library-with-yii/

Solution that works for me:

In file protected/extensions/phpexcel/XPHPExcel.php change this:

if (!self::$_isInitialized) {
    spl_autoload_unregister(array('YiiBase', 'autoload'));
    require(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'PHPExcel.php');
    spl_autoload_register(array('YiiBase', 'autoload'));

    self::$_isInitialized = true;
}

With this:

if (!self::$_isInitialized) {
    $extensionPath = Yii::getPathOfAlias('ext.phpexcel');
    require_once( $extensionPath . DIRECTORY_SEPARATOR .  'vendor' . DIRECTORY_SEPARATOR . 'Classes' . DIRECTORY_SEPARATOR . 'PHPExcel.php' );
    self::$_isInitialized = true;
}
marcovtwout commented 8 years ago

Can you post a full stack trace? My guess would be that in XPHPExcel.php, the require() fails because you are using a different vendor path.

alekir66 commented 8 years ago

@marcovtwout you have all the reason.

There was an error in my vendor folder content. I forgot to follow your instructions exactly. In your README.md you said:

3. Unzip the contents of the folder Classes to a new folder protected/extensions/phpexcel/vendor

I had vendor folder: phpexcel/vendor/Classes/PHPExcel instead phpexcel/vendor/PHPExcel. Fixing path as said in README.md works with no modification on your code.

marcovtwout commented 8 years ago

Great, thanks for verifying. I added a check in the code to prevent this obscure error. :)

alekir66 commented 8 years ago

@marcovtwout thank you for your great job