Yii Framework Forum: Fatal error: Class 'CException' not found in ... YiiBase.php - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Fatal error: Class 'CException' not found in ... YiiBase.php Rate Topic: -----

#1 User is offline   gandaliter 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 05-June 11

Posted 26 August 2011 - 03:31 PM

Hi,

I've written a few pages which show a CGridView, allow some filters etc., and have an export button which uses EExcelView (www.yiiframework.com/extension/eexcelview) to output the grid as a file. It works fine on my development machine, but when I put it on the server (in debug mode, just the same as my machine), clicking export gives the following error 'Fatal error: Class 'CException' not found in /var/www/yii/framework/YiiBase.php on line 321'.

Other exceptions get displayed just as normal, and indeed the rest of the site is absolutely fine, so I don't think there can be anything wrong Yii's code. So it must be something in my code or in EExcelView, but they work fine on my computer, and I can't imagine what kind of error could prevent Yii from being able to load CException.

Yii version is 1.1.8 on both machines. PHP is 5.3.2 on my machine, but 5.1.6 on the server. The server is running CentOS and my machine is running Ubuntu.

Any help would be much appreciated.
0

#2 User is offline   gandaliter 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 05-June 11

Posted 27 August 2011 - 07:15 AM

This has been solved now.

The actual problem was that the permissions on phpexcel (which EExcelView imports) were set so that Yii couldn't access them. The confusion happened because EExcelView disabled the yii autoloading function while it imported phpexcel (I think to hide an error that comes up when loading phpexcel otherwise). So when the error came up that yii couldn't access phpexcel it couldn't autoload CException so gave that fatal error.
0

#3 User is offline   denisa84 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 21-January 12

Posted 29 February 2012 - 10:33 AM

View Postgandaliter, on 27 August 2011 - 07:15 AM, said:

This has been solved now.

The actual problem was that the permissions on phpexcel (which EExcelView imports) were set so that Yii couldn't access them. The confusion happened because EExcelView disabled the yii autoloading function while it imported phpexcel (I think to hide an error that comes up when loading phpexcel otherwise). So when the error came up that yii couldn't access phpexcel it couldn't autoload CException so gave that fatal error.

I have the same problem, but I don't know how to fix it. What was the right fix for you?
Thanks,
0

#4 User is offline   rootbear 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 222
  • Joined: 17-June 11

Posted 29 March 2012 - 10:21 AM

View Postdenisa84, on 29 February 2012 - 10:33 AM, said:

I have the same problem, but I don't know how to fix it. What was the right fix for you?
Thanks,


i ran into the same error, here is how i fix it

in file EExcelView.php


public function init()
{
	$this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle();
	parent::init();
	//Autoload fix
	spl_autoload_unregister(array('YiiBase','autoload'));             
	Yii::import('application.extensions.phpexcel.Classes.PHPExcel', true);
	$this->objPHPExcel = new PHPExcel();
	spl_autoload_register(array('YiiBase','autoload'));  



error happens in

Yii::import('application.extensions.phpexcel.Classes.PHPExcel', true);


due to this line, Yii could not find Class 'CException' which comes with autoload

spl_autoload_unregister(array('YiiBase','autoload'));


so now, comment out this line first, Yii will throw user-friendly error message, fix the error (in my case, wrong import path for PHPExcel) and come back to remove the comment, voila!
I enjoy the Yii.sy coding life here.
0

#5 User is offline   denisa84 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 21-January 12

Posted 29 March 2012 - 10:26 AM

Hi,
Thank you very much. I will give it a try.


View Postrootbear, on 29 March 2012 - 10:21 AM, said:

i ran into the same error, here is how i fix it

in file EExcelView.php


public function init()
{
	$this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle();
	parent::init();
	//Autoload fix
	spl_autoload_unregister(array('YiiBase','autoload'));             
	Yii::import('application.extensions.phpexcel.Classes.PHPExcel', true);
	$this->objPHPExcel = new PHPExcel();
	spl_autoload_register(array('YiiBase','autoload'));  



error happens in

Yii::import('application.extensions.phpexcel.Classes.PHPExcel', true);


due to this line, Yii could not find Class 'CException' which comes with autoload

spl_autoload_unregister(array('YiiBase','autoload'));


so now, comment out this line first, Yii will throw user-friendly error message, fix the error (in my case, wrong import path for PHPExcel) and come back to remove the comment, voila!

0

#6 User is offline   ramasurf 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 06-February 12

Posted 22 May 2013 - 10:29 AM

Hi
I had the same problem and I changed this path:

public static $phpExcelPathAlias = 'ext.phpexcel.Classes.PHPExcel';

to this:

public static $phpExcelPathAlias = 'ext.PHPExcel.Classes.PHPExcel';

thanks
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users