I have a shared library written in C Language on Linux environment.
How to expose those shared library API's to REST based PHP WebService?
If you don't want to do it the "exec" way, you will have to do some work before you can get it working directly from within php.
Check this http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/ tutorial.
You will have to write a config.m4 file and put PHP specific includes and variables in your C code.
Check this answer:
Linking a PHP Extension Written in C
It's a good example.
It's a little ugly, but you can do methods in your PHP REST Api to call the process via system, exec, passthru... parse the info returned by the library and return the result in json format by the PHP Api.
Related
I have two specific questions and I hope someone can answer either of them:
Is there a way to provide MediaWiki's mw library to a stand-alone lua script?
Is there an API command or property that exposes the output of a dynamic module?
Background: I am trying to figure out how to access the output of a wiktionary module (in this case, pron-th). This is a module that can be dynamically inserted by editors to show transliteration (pronunciation) of Thai words. For example, whenever an editor has added this line:
{{th-pron|ไคฺร่}}
...the server will run the Lua script documented found here and outputs a table showing the various transliterations (example). However, this output is specifically excluded when doing API requests (example) and I cannot find an endpoint that includes this data. And running the lua script directly fails because it is missing several imports, such as mw.ustring, mw.text, etc., which I believe are defined in a PHP include higher up their software stack. I have significant PHP experience but none with Lua, so I am sort of at a loss here.
Short of calling up each page directly and scraping the data, I can't think of a way to do this.
The MediaWiki mw library is part of the Scribunto extension (see https://github.com/wikimedia/mediawiki-extensions-Scribunto/tree/master/includes/engines/LuaCommon/lualib), and has a lot of dependencies back to MEdiawikis php core, so it won't be easy to just import that.
You could render that wikitext via API like https://en.wiktionary.org/w/api.php?action=parse&text=%20{{th-pron|%E0%B9%84%E0%B8%84%E0%B8%BA%E0%B8%A3%E0%B9%88}}&contentmodel=wikitext and parse the output, or you could try and replace the MediaWiki specific function calls with other function calls to some native Lua library.
Recently I've been working on web page based remote control. the function is already there done by c++ and now I'm trying to find a way linking this function to my web page.
I tried using soap and now almost give up because of those "cannot load wsdl file" and "http get method not implemented" errors
Is there any other way to do this beside using soap?
Cheers
Do you really want to use PHP?
You can also put the webpage stuff in the C++ application and make it a (fast)cgi application or by using a framework like wt or CppCMS
This sounds rather general so here are some possible directions:
Bind C++ to a custom php module
Call C++ binary with php system('')
Maintain a control socket (TCP / UDP /...) in C++ Daemon and connect from PHP
Integrate C++ in other Application Framework than PHP (.Net, ...)
As for the soap errors, what did you use to wrap your C++ into a SOAP Provider?
can any one help me in developing soap client whereas parameters type of soap server's functions is object etc.
$client->__call("functionName",array(/*now how to find parameter type if they are object*/));
thanks ...
Just read the official documentation (http://php.net/manual/en/class.soapclient.php). There are plenty of examples, you only have to copy, paste and adapt them.
If you really don't know how to use SOAP in PHP then try to use a WSDL to PHP generator such as PackageGenerator. With this is you'll have a PHP SDK corresponding to SOAP Web Service using the native PHP SoapClient class. A tutorial file is also generated that can be used as a starting guide.
Read my question thoroughly before responding, I know there’s a site called wonderfl.net
I‘ve got the Flex SDK 4 on my Mac and I found a way to compile AS3 into SWF files using Flex's mxmlc compiler in Xcode, so I wondered, would it be possible to do this sort of simply online? Using for example a language I'm familiar with, PHP?
I thought it’d be a thing that would be interesting to use for a website, or like some private projects.
Thanks in advance!
You have the available tools to do so. You can write the AS3 content posted from the web into files, use PHP's exec function to run mxmlc, then send the resulting .SWF file to the client using PHP's readfile function. You'd just have to make sure mxmlc was present on the web server running the PHP.
I have a VPS Linux webserver with PHP installed.
I want to code some search engine or data mining stuff in one application which I am thinking of building in python.
I want to know if it is possible to use python and php together like calling functions of python in php and vice versa.
As it is my VPS server, I can install anything on that.
Has anyone tried using python in php? Are there any performance issues in real time??
You can execute python scripts using the exec() function in your php script.
Also this seems to provide an answer or two to your question.
Calling Python in PHP
You could have a look at PiP
To that end, I've [site author] written a Python extension for PHP. In short, this extensions allows the Python interpretter to be embedded inside of PHP (think of PHP as the parent language with Python as its child). This allows native Python objects to be instantiated and manipulated from within PHP. There is also initial support for accessing PHP functions and data from within the embedded Python environment.
However, I cannot comment on its reliability. Might need to test it for yourself.
You're trying to do something like
def helloWorld():
print 'Hello, World'
<?php helloWorld(); ?>
I'd say that you most certainly can't.
Edit: Have a look at php's shell_exec though.
I think that should be
<?php
$try = exec("/var/htdocs/folder/test.py")
?>
Try and see if it works
Better you have to do, use api, different application like one application on python server having python application and one server having php application with api. Like you store or delete data by using api in android or ios.