Yii Framework Forum: How to instance a class that have different name with it's file name?? - Yii Framework Forum

Jump to content

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

How to instance a class that have different name with it's file name?? Rate Topic: -----

#1 User is offline   munemune 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 07-November 09

Posted 21 December 2009 - 12:28 AM

Hi, right now i am try to use 3rd party library for extracting my data to excel using lib PHPExcel (http://www.phpexcel.net/).

The problem is the name of class is different with its file name.

For example class "PHPExcel_Writer_Excel5" is in file name "Excel5.php".

When i try to instance it (new PHPExcel_Writer_Excel5) yii return error "file not found". If i change my instance to its file name (new Excel5), yii not return any error but the lib wont work.

Any solution ?? Of course Except changing all class PHPExcel_Writer_Excel5 in file Excel5.php, to class Excel5

Thank you
0

#2 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 21 December 2009 - 02:56 AM

View Postmunemune, on 21 December 2009 - 12:28 AM, said:

Hi, right now i am try to use 3rd party library for extracting my data to excel using lib PHPExcel (http://www.phpexcel.net/).

The problem is the name of class is different with its file name.

For example class "PHPExcel_Writer_Excel5" is in file name "Excel5.php".

When i try to instance it (new PHPExcel_Writer_Excel5) yii return error "file not found". If i change my instance to its file name (new Excel5), yii not return any error but the lib wont work.

Any solution ?? Of course Except changing all class PHPExcel_Writer_Excel5 in file Excel5.php, to class Excel5

Thank you


Create a new dummy class inside of the Excel class maybe?

class Excel5 extends PHPExcel_Writer_Excel5 {}

0

#3 User is offline   Sander 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 169
  • Joined: 03-November 09
  • Location:Amsterdam, Netherlands

Posted 21 December 2009 - 03:38 AM

View Postmunemune, on 21 December 2009 - 12:28 AM, said:

Any solution ?? Of course Except changing all class PHPExcel_Writer_Excel5 in file Excel5.php, to class Excel5

Uhm, how about renaming the file?

Otherwise you can just manually include it in the relevant controller(s).
0

#4 User is offline   munemune 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 07-November 09

Posted 21 December 2009 - 11:28 AM

@Y!! : Its still give me error (a blank page to be exactly)

@Sander : Yes that what i thought at first (before i post this), but renaming all file and class would be tedious work. PHPExcel have many file and each other connected, more worst every file and every class have different name only main class that have same name with file name.

Anyway rightnow i got much simpler solution for extracting data to excel (not "feature full" but its works). Editing/using the view script.

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