c++ extension in php yii framework - php

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();

Related

Use functions to dll in php on windows

I need to use the functions of a dll using php. I have read that through the COM class I can call their methods and access their properties in php. This is my code for test:
<?php
$obj = new COM("myfile.dll");
$output = $obj->Initial(); // Call the "Initial" method in the dll
But show this error:
error: Failed to create COM object `CyTconnect': Sintaxis no v�lida
I use windows, Apache, Php 7.1.12, activate the php com_dotnet extension, and register the dll with REGSVR32. Any suggestion?

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(...)

ZipArchive not installed in xampp?

I have newest version of XAMPP and php version 5.6.3, but I can't use ZipArchive. I've downloaded php_zip.dll and placed it in ext dir, I've added extension=php_zip.dll but after server reset I have warming :
"Module 'zip' already loaded"
I still see error: ZipArchive not found ...
using:
$zip = new ZipArchive();
returns error:
Fatal error: Class 'Att\Controller\ZipArchive' not found in ...
OK, given the additional information you added upon my suggestion in the comment things become more clear now. This looks like you have a namespacing issue here: php tries to locate the class Att\Controller\ZipArchive, not the class ZipArchive. This is probably the case because you try to use the class inside a namespaced script. In that case php will assume all class names as local to the general namespace as declared at the beginning of the script unless they are noted with a specific namespace reference.
Try makeing the class name to reference the global namespace explicitly. So instead of
$zip = new ZipArchive();
do this:
$zip = new \ZipArchive;
(Note the back slash (\) before the class name. Also you can drop the empty brackets trailing it, since they are empty.)
Now php will try to locate a class called "ZipArchive" in the global namespace (\) and (hopefully) succeed... This is a general effect of namespacing in php and has nothing to do with the specific class you are trying to use.
You may want to read a bit about php and namespaces. Take a look into the documentation: http://php.net/manual/en/language.namespaces.php
stop the xampp and then kindly remove the starting semicolon ( ; ) before ;extension=zip from your xampp/php/php.ini the following code, and start xammp again .

Word to HTML conversion not working - PHP + ZEND

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_');

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