Jump to content

ZendFramework & Livedocx


itachi77

Recommended Posts

Hi all, seem to be having some trouble getting these two to work together.  I have followed this video tutorial : http://www.videophpblog.com/2008/06/15/installing-zend-framework/

In this i have downloaded the full zend framework and extracted to C: I have then taken the Zend folder in the library folder of Zend Framework and copied to C: . My webroot is also at C: .  I have then edited the include in the php.ini file in the php folder to point to the Zend library folder so it looks like this: 

 

include_path = ".;c:\php\includes;c:\Zend"  

 

phpinfo() runs fine, I see the include path in it.

I have put the template.docx file in the webroot folder and when i run this script:

<?php
$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();

$phpLiveDocx->setUsername('******')
            ->setPassword('******');

$phpLiveDocx->setLocalTemplate('template.docx');

$phpLiveDocx->assign('Name', 'Mr. B')
            ->assign('Venue', 'Radisson SAS')
            ->assign('Date','06/07/08')
            ->assign('NumberofPeople',  '10');

$phpLiveDocx->createDocument();

$document = $phpLiveDocx->retrieveDocument('pdf');

file_put_contents('document.pdf', $document);

?>

 

I get the error : 

Fatal error: Class 'Zend_Service_LiveDocx_MailMerge' not found in C:\public_html\ZendTest.php on line 2

 

I am sure I am missing something but the tutorial did not say anything else.  I am using apache and the server is running fine.  I have tried running the check environment script in the demos/service/livedocx folder but that shows the following error:

Warning: require_once(Zend/Date.php) [function.require-once]: failed to open stream: No such file or directory in C:\public_html\Helper.php on line 25

 

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Date.php' (include_path='.;c:\php\includes;c:\Zend') in C:\public_html\Helper.php on line 25

 

Any help would be appreciated, thanks, i have come across a few tutorials and they all seem to be different so i'm a little confused on where to go from here. 

Link to comment
https://forums.phpfreaks.com/topic/206874-zendframework-livedocx/
Share on other sites

You need to either copy the library folder (containing Zend) to your C:\ drive (and leave your include path as is), or place C:\ on your include path (and remove C:\Zend).

 

Then, if you haven't (and are not going to) actually bootstrapped any Zend application your going to need to include the class yourself.

 

<?php
require_once 'Zend\Service\LiveDocx\MailMerge.php';

$phpLiveDocx = new Zend_Service_LiveDocx_MailMerge();

$phpLiveDocx->setUsername('******')
            ->setPassword('******');

$phpLiveDocx->setLocalTemplate('template.docx');

$phpLiveDocx->assign('Name', 'Mr. B')
            ->assign('Venue', 'Radisson SAS')
            ->assign('Date','06/07/08')
            ->assign('NumberofPeople',  '10');

$phpLiveDocx->createDocument();

$document = $phpLiveDocx->retrieveDocument('pdf');

file_put_contents('document.pdf', $document);

?>

Thanks for the prompt reply, I have now set the include as :

include_path = ".;c:\php\includes;c:\"

And have added the

require_once 'Zend\Service\LiveDocx\MailMerge.php';

to the top of the above script.  I now get a new error :

Notice: Use of undefined constant SOAP_1_2 - assumed 'SOAP_1_2' in C:\Zend\Service\LiveDocx.php on line 189

 

Fatal error: Uncaught exception 'Zend_Soap_Client_Exception' with message 'SOAP extension is not loaded.' in C:\Zend\Soap\Client.php:152 Stack trace: #0 C:\Zend\Service\LiveDocx.php(189): Zend_Soap_Client->__construct() #1 C:\Zend\Service\LiveDocx.php(249): Zend_Service_LiveDocx->_initSoapClient('https://api.liv...') #2 C:\Zend\Service\LiveDocx\MailMerge.php(88): Zend_Service_LiveDocx->logIn() #3 C:\public_html\ZendTest.php(10): Zend_Service_LiveDocx_MailMerge->setLocalTemplate('template.docx') #4 {main} Next exception 'Zend_Service_LiveDocx_Exception' with message 'Cannot connect to LiveDocx service at https://api.livedocx.com/1.2/mailmerge.asmx?WSDL' in C:\Zend\Service\LiveDocx.php:193 Stack trace: #0 C:\Zend\Service\LiveDocx.php(249): Zend_Service_LiveDocx->_initSoapClient('https://api.liv...') #1 C:\Zend\Service\LiveDocx\MailMerge.php(88): Zend_Service_LiveDocx->logIn() #2 C:\public_html\ZendTest.php(10): Zend_Service_LiveDocx_MailMerge->setLocalTemplate('template.docx') #3 {main} thrown in C:\Zend\Service\LiveDocx.php on line 193

Any ideas? Thanks

I have now uncommented the

extension=php_soap.dll
in the php.ini file and the other soap settings look like this :

[soap]

; Enables or disables WSDL caching feature.

; http://php.net/soap.wsdl-cache-enabled

soap.wsdl_cache_enabled=1

 

; Sets the directory name where SOAP extension will put cache files.

; http://php.net/soap.wsdl-cache-dir

soap.wsdl_cache_dir="/tmp"

 

; (time to live) Sets the number of second while cached file will be used

; instead of original one.

; http://php.net/soap.wsdl-cache-ttl

soap.wsdl_cache_ttl=86400

 

; Sets the size of the cache limit. (Max. number of WSDL files to cache)

soap.wsdl_cache_limit = 5

 

 

I am now getting a slightly different error:

Fatal error: Uncaught exception 'SoapFault' with message 'SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://api.livedocx.com/1.2/mailmerge.asmx?WSDL' : failed to load external entity "https://api.livedocx.com/1.2/mailmerge.asmx?WSDL" ' in C:\Zend\Soap\Client\Common.php:51 Stack trace: #0 C:\Zend\Soap\Client\Common.php(51): SoapClient->SoapClient('https://api.liv...', Array) #1 C:\Zend\Soap\Client.php(1024): Zend_Soap_Client_Common->__construct(Array, 'https://api.liv...', Array) #2 C:\Zend\Soap\Client.php(1180): Zend_Soap_Client->_initSoapClientObject() #3 C:\Zend\Soap\Client.php(1104): Zend_Soap_Client->getSoapClient() #4 [internal function]: Zend_Soap_Client->__call('LogIn', Array) #5 C:\Zend\Service\LiveDocx.php(256): Zend_Soap_Client->LogIn(Array) #6 C:\Zend\Service\LiveDocx\MailMerge.php(88): Zend_Service_LiveDocx->logIn() #7 C:\public_html\ZendTest.php(10): Zend_Service_LiveDocx_MailMerge->setLocalTemplate('template.docx') #8 {main} Next exception 'Zend_Service_LiveDocx_Exception' with message 'Cannot login int in C:\Zend\Service\LiveDocx.php on line 260

Hi I managed to solve the above error by uncommenting

extension=php_openssl.dll
in the php.ini file.  Apparently i needed to enable https stream wrapper.  The output document is created in the webroot folder, is there a way to specify where to output the document? And where to take the template in from?

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.