Forum


Replies: 7   Views: 4521
How to integrate phpdocx with yii framework?
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by vijay  · 16-09-2013 - 17:32

On a standalone php script, all I have to do to include phpdocx is 



require_once '../phpdocx_pro/classes/CreateDocx.inc';



How do I include phpdocx in Yii? I've my files in components/thirdparty/phpdocx


Posted by admin-phpdocx  · 18-09-2013 - 08:43

There may be conflict with the autoloaders when you want to ingterate PHPDocX within a PHP framework.



We have explicitly worked it out with other frameworks like Simfony but not yet with Yii.



Anyhow we do not expect it to be an unsurmontable problem :-)



Let us have a look at it and we will get back toy you...


Posted by vijay  · 18-09-2013 - 15:50

That would be very helpful.  I'm not able to do much (for example, MergeDocx is also not working - because it can't find Yii's CException class). Thank You.


Posted by tarzip  · 14-11-2013 - 00:14

I hope you have found the solution.



In the start we also faced similar problem but this fixed teh issue.



in  config/main.php in 'import'



'application.modules.phpdocx.classes.*',

        'application.modules.phpdocx.lib.*',

        'application.modules.phpdocx.lib.dompdfParser.*',

        'application.modules.phpdocx.lib.fpdf-tpl.*',

        'application.modules.phpdocx.lib.fpdi.*',

        'application.modules.phpdocx.lib.log4php.*',

        'application.modules.phpdocx.lib.log4php.appenders.*',

        'application.modules.phpdocx.lib.log4php.configurators.*',

        'application.modules.phpdocx.lib.log4php.filters.*',

        'application.modules.phpdocx.lib.log4php.helpers.*',

        'application.modules.phpdocx.lib.log4php.layouts.*',

        'application.modules.phpdocx.lib.log4php.pattern.*',

        'application.modules.phpdocx.lib.log4php.renderers.*',



 



 



and use following code where you create new CreateDocx or other PhpDocx object




require_once '/path-to-phpdocx/classes/AutoLoader.inc';

spl_autoload_unregister(array('YiiBase','autoload'));
AutoLoader::load();
spl_autoload_register(array('YiiBase','autoload'));




Or




require_once '/path-to-phpdocx/classes/AutoLoader.inc';

Yii::registerAutoloader(array("AutoLoader", "load"));


 



 


Posted by jorgelj  · 14-11-2013 - 10:17

Hello,



There's this post:



www.phpdocx.com/blog-news/using-phpdocx-yii



About how to integrate PHPDocX with Yii.



Regards.


Posted by tarzip  · 14-11-2013 - 21:45

Thanks for reply.



At first we used the approach mentioned in your post but it failed. Then we added all the subpaths in yii import config variable and it worked and never tried again the other way.



I'll try the way you mentioned also. It will reduce 13 line to just 1 in YII import.



I see you are not using phpdocx autoloader. I'll reply back after using mix of your and ours config options to see if it works or not.



 



Thanks


Posted by jorgelj  · 15-11-2013 - 07:37

Hi,



This line:



require_once'classes/CreateDocx.inc';



imports the Autoloader. Of cource if you find any issue please write a post to check it.



Regards.