Word to HTML conversion not working - PHP + ZEND - php

Am new to PHP and this is my first time using Zend Framework to convert a Word file to HTML file. I am using this code.
<?php
$mailMerge = new Zend_Service_LiveDocx_MailMerge();
$mailMerge->setUsername('myUsername')->setPassword('myPassword');
$mailMerge->setLocalTemplate('docs/file.docx');
$mailMerge->assign(null);
$mailMerge->createDocument();
$data = $mailMerge->retrieveDocument('html');
file_put_contents('docs/file.html',$data);
?>
Copied from http://www.phplivedocx.org/2009/08/13/convert-docx-doc-rtf-to-html-in-php/
I've even included the path of Zend in php.ini file.
include_path = ".;c:\php\includes;C:\ZendFramework-1.12.11\library"
But its still showing me the error.
Fatal error: Class 'Zend_Service_LiveDocx_MailMerge' not found in C:\wamp\www\word2html_zend\index.php on line 2
I've googled it and also searched in stackoverflow search.. But no solution worked for me.. What should I do to get the code to work?
EDIT::
Am using Windows 8 operating system and PHP version 5.5.12

it is not enough included the path for Zend. You need to register Zend autoloader before calling any class from Zend library,
like
// Initialize application loader
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance()->registerNamespace('Zend_');

Related

How to require Java.inc in laravel

I configure Java bridge with tomcat. Which is accessible in http://localhost:8080/JavaBridge/java/Java.inc.
In core php we use require_once to include file. require_once("http://localhost:8080/JavaBridge/java/Java.inc");
$myObj = new Java("com.fss.plugin.iPayPipe");
It works fine in core PHP. But it is not work in Laravel.
It shows an error Class 'Java' not found.
Please Help
Have a look at what is displayed when you open http://localhost:8080/JavaBridge/java/Java.inc in a browser - is it PHP code? If yes, try to output the result on your webserver through echo file_get_contents("http://localhost:8080/JavaBridge/java/Java.inc"); - is that still PHP code?
Maybe there is an import you are missing - if the Java class is not in a namespace, but your Lavarel code is, you should instantiate the class using $myObj = new \Java(...)

c++ extension in php yii framework

I want to use C++ extension in yii. I have already compile .so file and successfully used in php script. But when I used it in yii framework, it occurs that "class not found",anyone knows why?
The C++ extension is rdkafka.so : https://github.com/arnaud-lb/php-rdkafka
$conf = new RdKafka\Conf();
$conf->set("ssl.key.location","./conf/client.key");
$conf->set("ssl.certificate.location","./conf/client.pem");
$conf->set("ssl.ca.location","./conf/ca.pem");
$conf->set("security.protocol","SSL");
If you are running this code in a namespaced file, you need to either import the class, or prefix it with a \:
$conf = new \RdKafka\Conf();

Missing XMLReader Class

I am playing around with parsing spreadsheets and found the spreadsheet-reader class. I installed and have a very simple program written to open and parse an ".ODS" spreadsheet file. When I run it I get the error:
PHP Fatal error: Class 'XMLReader' not found in...
The line in question:
$ss = new SpreadsheetReader("test.ods");
So I google around and find out the version of PHP on that system needs to be at least 5.1 for it to use the version of XMLReader built into the core of PHP. I am using 5.4.12 there. I check with php -i and find PHP was compiled with: '--enable-xmlreader=shared'. According to the docs nothing needs to be configured at runtime to enable it.
Where else can I check and what am I doing wrong?
The solution is because PHP was built with a shared object file you DO need to modify php.ini: extension=xmlreader.so.

php 5.6.11 xampp xml worse formatted

Today, I work with Zend 6.3 community edition. This version include PHP Version 5.5.7.
I use php and mySQL to load data inside Adobe Air application by httpService with e4x result.
As I work with french language I had to manage characters with french accent.
Today, I use this function
function htmlPHP54($string) {
return htmlspecialchars($string, ENT_QUOTES,'ISO-8859-1');
}
Therefore each time I need to generate my xml file, I do something like that:
$return = "<rootsPHP>";
$return.="<name>".htmlPHP54($row_recordset['name'])."</name >";
$return. = "</rootsPHP>";
This method works well with Zend 6.3 and PHP 5.5.7
But today with Xammp (php 5.6.1), an error appears:
Error #1088: The markup in the document following the root element must be ... in the document follwing the root element must be well-formed”.
In fact when I try to open result file inside browser, the same error appear.
So I need help to solve that. What parameter must be changed inside php.ini or my.cnf?

Class 'Zend_Search_Lucene' not found

A big beginner of Zend-framework on PHP calls, I could include it on Netbeans IDE. Now I'm trying to use it to achieve a Lucene indexer and searcher using Zend_Lucene, I followed the getting started of the official site, unfortunately they explain the whole thing with just few words. Anyway, I copied pasted this $index = Zend_Search_Lucene::create($indexPath);, but I got a message onto this line saying: Fatal error: Class 'Zend_Search_Lucene' not found in C:\wamp\www\witswork\luceneTry.php
means that the function still unknown, maybe, some files need to be copied on my project folder but really I'm running out of ideas right now.
Accept my regards,
dany90.
You need to load the php file which contains the Zend_Search_Lucene class first. One option is to load your/path/to/library/Zend/Search/Lucene.php:
require_once 'my/path/to/library/Zend/Search/Lucene.php';
$index = new Zend_Search_Lucene::create($indexPath);
This class loads all its dependencies, so you don't need to worry about that.
Another option is to use the autoloader of Zend, Zend_Loader_Autoloader. This class is a singleton and registers itself with spl_autoload() when you retrieve it for the first time:
$autoloader = Zend_Loader_Autoloader::getInstance();
$index = new Zend_Search_Lucene::create($indexPath);
After the autoloader is loaded, you just can use Zend_Search_Lucene without the require_once() call. In the manual of Zend Framework you can find more information about the autoloader.

Categories