Forum


Replies: 4   Views: 6961
Createdocxfromtemplate is not available
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 Ronster1975  · 23-07-2014 - 16:56

When installed manually or via Composer in our Symfony2 project, we cannot use the CreateDocxFromTemplate class. Whilst the following works: $docx = new \CreateDocx(); the following does not: $docx = new \CreateDocxFromTemplate('path\to\some\template.docx'); CreateDocxFromTemplate is simply not available. What are we doing wrong? We cannot upgrade to the paid-for version unless we can achieve template variable replacement, and there is apparently no way to load a template into the CreateDocx object that doesn't completely replace its contents as soon as any action is performed on it.

Posted by admin  · 24-07-2014 - 11:54

Hello, There must be an issue/error in your code. The published post is Symfony 2.0/2.1 compatible. We are almost finishing a Symfony 2.3/2.4/2.5 post. You can ask for it at contact@phpdocx.com. Regards.

Posted by esai  · 07-11-2014 - 17:58

hi, I also have problem with CreateDocxFromTemplate(). I downloaded the trial version and hooked it to a module in ZF2. I can call CreateDocx() but CreateDocxFromTemplate() fails. I get error Fatal error: Class 'CreateDocxFromTemplate' not found in.... and the obfuscated content of CreateDocxFromTemplate.inc is dumped to browser. How did you solve this?

Posted by admin  · 08-11-2014 - 07:53

Hello, What license and version of phpdocx are you using? Regards.

Posted by esai  · 08-11-2014 - 11:08

We are testing with the demo license on osx and linux wit ZF2. I checked the example code (examples/Templates/...) I realised that I was not calling the function properly. This was my mistake. This is our code now: Module.php: public function getAutoloaderConfig() { return array( 'Zend\Loader\ClassMapAutoloader' => array( __DIR__ . '/autoload_classmap.php', array( 'CreateDocx' => __DIR__ . '/../../external/phpdocx/classes/CreateDocx.inc', ), ), 'Zend\Loader\StandardAutoloader' => array( 'namespaces' => array( // if we're in a namespace deeper than one level we need to fix the \ in the path __NAMESPACE__ => __DIR__ . '/src/' . str_replace('\\', '/' , __NAMESPACE__), ), ), ); } And in the controller: ... /* * First we must call CreateDocx() because that loads the requires phpdocx code. */ $docx = new \CreateDocx(); /* * Now we can use the actual template class. */ $docx = new \CreateDocxFromTemplate($templatefile); .... Now CreateDocxFromTemplate() works and we can continue evaluating. Thanks.