This project is read-only.

Basic Example Not Working

Oct 28, 2011 at 3:57 AM

I cannot get the basic example to work.  I've unzipped the files to my site folder.  I made a new folder in the root directory of my site called "phpword".  So inside of phpword is the contents of the zip file which are the PHPWord folder and PHPWord.php.  Ok, so the only change I made to the basic example was to the require_once line:


I then changed the base path in the PHPWord.php file to reflect my site directory:



if(!defined('PHPWORD_BASE_PATH')) {

	define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/');

	require PHPWORD_BASE_PATH . 'phpword/PHPWord/Autoloader.php';



When I try to run the example, I get two errors:


Warning: require(C:\wamp\www\mysite\phpword/phpword/PHPWord/Autoloader.php) [function.require]: failed to open stream: No such file or directory in C:\wamp\www\mysite\phpword\PHPWord.php on line 31

Fatal error: require() [function.require]: Failed opening required 'C:\wamp\www\mysite\phpword/phpword/PHPWord/Autoloader.php' (include_path='.;c:\ZendFramework\library') in C:\wamp\www\mysite\phpword\PHPWord.php on line 31

One thing I noticed is that there is a mix of / and \ in the path.  I have no idea why it would be doing this.  In any case I can't even get the basic example to work.  If someone could help I'd appreciate it.

Oct 28, 2011 at 4:36 AM

Well I figured out part of it at least.  I noticed that phpword was getting called twice in the path.  So I just decided to take everything out of the folder and put it right in the site root.  It actually ran this time, but I got a new error:

Fatal error: Call to undefined method PHPWord_Section_Text::setBold() in C:\wamp\www\mysite\test.php on line 24

Underneath the example are newer examples for working with text.  So I got rid of any lines styling text in the basic example and replaced them with:

$styleFont = array('bold'=>true, 'size'=>16, 'name'=>'Calibri');

So I finally got it to run, however the .docx file that is created does not open.

Oct 28, 2011 at 5:32 AM

Ok, I was running open office 3.2.  Upgraded to 3.3 and it works great.  It would be nice if the basic example was updated to reflect the newer changes though.