I’ve got a version of the A* algorithm that builds a graph of the
UK road and cycle network in Python lists. It takes about 30 seconds
to initialise, but once done can very quickly find the shortest route
between any two vertices. The start and finish vertex ids are provided
by PHP.
I’m trying to work out the best way of communicating between
PHP and the Python program. I only want to do the initialisation phase
when the Apache server starts, so my question is: How do I keep the
python program alive and request routes from it via php? I have a
GLAMP setup.
Easiest way that I can think of would be XMLRPC. Python makes it horribly easy to set up an XMLRPC server, and there’s php_xmlrpc for bindings on the PHP side…
and you’re running and should be able to do an XMLRPC call for
calculate_pathon http://localhost:9393/ from your PHP app.