This project is read-only.

Help with PHPword coding

Oct 21, 2014 at 3:52 PM
Edited Oct 21, 2014 at 3:59 PM
Hi all, I am very new to PHPword, that is to say, I only installed it today because after months of searching it is exactly what I need.

I am currently working with PHPRunner, which is a 3rd party PHP coding application and a great piece of kit, it comes with PHPexcel already included as a plugin.

The application runs from public_html/portal, note that it is not the main root, it is a subdomain, the plugins where PHPExcel, and now PHPWord are installed is public_html/portal/plugins.

On my application I have included the following code to the 'after initialisation' script in order to register the PHPWord application:
> //Initiate PHPword
require_once '/home/sites/iso-drive.co.uk/public_html/portal/plugins/PHPWord/Autoloader.php';
'\home\sites\iso-drive.co.uk\public_html\portal\plugins\PHPWord\Autoloader::register()';
Then in a separate event code, I am trying to use this code:
//test with PHPWord
require_once '/home/sites/iso-drive.co.uk/public_html/portal/plugins/PHPWord/Template.php';
require_once '/home/sites/iso-drive.co.uk/public_html/portal/plugins/PHPWord.php';
$template = $PHPWord->loadTemplate('$name1');
$template->save('/Templates/test.docx');
unset($template);
Obviously at this point I am just wanting to create a test document, to load from a template and resave. Once I have this working I will attempt to play with the document more.

However I am now getting the following error:
Fatal error: Call to a member function loadTemplate() on a non-object in /home/sites/iso-drive.co.uk/public_html/portal/include/global_companies_events.php on line 110
phpinfo file is here

If I remove any of the code I then get fatal error, cannot redeclare etc.

I'd be very grateful for some assistance.

PS.

If I change code to:
require_once '/home/sites/iso-drive.co.uk/public_html/portal/plugins/PHPWord/Template.php';
require_once '/home/sites/iso-drive.co.uk/public_html/portal/plugins/PHPWord.php';
$PHPWord = new PHPWord();
$template = $PHPWord->loadTemplate('$name1');
$template->save('/Templates/test.docx');
unset($template);
Then I get the following error:
Fatal error: Cannot redeclare class PHPWord_Autoloader