PHP which component for laravel with prolog - php

I would like to ask you if there is any component that I can use to connect laravel and prolog
Thanks

You haven't said which prolog supplier you wish to connect to, but swi-prolog comes with an http server package, which handles regular http GET and POST requests from any http client.
It is possible to call swi prolog from the console from php, but http is much, much faster, as you're not shelling out to a console each time.
I don't know anything about Laravel, but a quick search shows it natively supports http via 'routes', so it should be possible in theory.
I have also successfully called swi prolog server from a php curl client. Laravel seems to have support for curl, so that be another way to initiate the http client GET/POST request.

There is the abandoned https://packagist.org/packages/prologue/phpconsole for Laravel 4, or it's replacement https://packagist.org/packages/phpconsole/phpconsole that you might consider.

Related

Comet with curl or wget

How can I create Wget/curl request to comet server
I have a php based server and embeded linux machine I have to create listener from client side but not based on browser and it must not use sockets.
I think you are referring to that one facet of Comet where a server-client connection remains open on an unfinished http request for a long(ish) period of time. I honestly don't think that it would be wise to do that with simple scripting of wget or curl, however it's completely possible to use libcURL (the library that cURL is built around) for such a purpose. Daniel Stenberg, author of cURL and libcURL himself said so:
AFAIK, COMET is just HTTP done in a slightly funny way but still plain HTTP
and libcurl should be able to do it fine. Even if COMET also is a what
wikipedia calls an "umbrella term" which seems to include a lot of different
approaches.
Just one thing (re the socket remark): do realize that "below" whatever solution you'll choose there will be a socket transporting the data, because that's how http gets over the wire.

Custom AJAX Server

I have been looking at writing my own server using kqueue. I can do this with really no problems as long as I can control what kind of client will be accessing our system. Realistically, however, I would need to accept from standard web clients, including AJAX. I have been looking for examples of programs that use XMLHTTPRequest to connect to a custom server written in C. I have found nothing.
Can you help me?
Bruce
Ajax just means "Making an HTTP request using JavaScript". It isn't a client.
As far as the server is concerned, there is no difference between an Ajax request and any other HTTP request.
(Some libraries add an experimental HTTP header to state that the request was trigged by Ajax, but when you care about that on the server, it is almost always at the application level rather than the server level (i.e. your server side script not your HTTPD)).

Fastest way to Fire and Forget a JSON POST in PHP

I'm currently in the process of building/implementing a logging system for a website I'm working on that's in PHP. The way the logging system works is I send a JSON request to localhost and that json gets logged (basically, anyway.
My question is:
what's the fastest way I can make a quick fire and forget call with a JSON POST? Is there a way to fire and forget with cURL?
There are multiple ways to do it: you could use the curl_multi functionality of the php_curl extension, which allows you to send asynchronous HTTP requests using cURL, but this requires that extension. GuzzlePHP provides a large wrapper around much of the functionality of cURL, including the curl_multi features if you are looking for an object-oriented approach. PHP's sockets also support asynchronous communications, a library which implements this for the HTTP protocol is available here [the client is written in "pure" PHP and has no dependency on cURL but supports asynchronous requests and fully complies with the HTTP 1.1 spec].
If you are looking for a fire and forget logging solution you might want to look at something that uses UDP protocol like Graylog.
You could use a small image that hits a PHP script. The php script logs the hit and returns a tiny 1x1 transparent GIF. Then the logging will happen after the page loads.

CORBA broker / proxy over HTTP or accessible via sockets (for PHP)?

I'm looking at connecting an existing PHP codebase to a remote CORBA service. All actual data is passed via XML so I don't think I need an IDL to PHP mapping for remote invocation. I just need to connect to the CORBA service, transmit to it the XML string, and read the XML response.
After some research on this I found the CORBA4PHP PHP extension which I'm about to try although am having some reservations (last updated in 2009). I also found numerous implementations in Java and Python.
To avoid dealing with a new PHP extension I'm wondering if there exists a CORBA HTTP proxy of sorts in any language that would take care of communicating with the CORBA service. I would HTTP POST to the proxy (or some socket communication), it would relay it to the CORBA service, and relay back to me its response.
Does such a proxy exist?
I don't know of such a service, but perhaps others might know of one. That said, given how simple your IDL is, I would just go ahead and try the CORBA4PHP extension and use that if it works.
If it doesn't work (I've no idea about its quality), it would be really simple to build such a proxy yourself:
Download a free ORB (let's say you get one for Java, say JacORB)
Compile your IDL and build a client to the CORBA service
Add a front-end API to your Java application which your PHP code will use to call it and pass in the string parameter containing your XML (POST sounds reasonable, and there are plenty of ways to implement such a thing in Java)

Send data between two PHP scripts

I want to have a PHP script send a XML formatted string to another PHP script that resides on a different server in a different part of town.
Is there any nice, clean way of doing this?
(PHP5 and all the latest software available)
check out cURL for posting data between pages.
If it were me, I would just POST the xml data to the other script. You could use a socket from PHP, or use CURL. I think that's the cleanest solution, although SOAP is also viable if you don't mind the overhead of the SOAP request, as well as using a library.
I strongly suggest rolling your own RESTful API and avoiding the complexity of SOAP altogether. All you need is the curl extension to handle the HTTP request/response, and simple_xml to build/process the XML. If your data is in a reasonable format, it should be easy for you to push it into an XML string and submit it as a POST to the other server. That server will respond to the request by reading the XML string from the POST var back into an object, and voila! It shouldn't take you all day to whip this out.
XML-RPC or SOAP or just a RESTful API
You can use cURL (complex API), the http extension (cleaner), or if you need to do more complex stuff you can even use the Scriptable Browser from simpletest.

Categories