I need to run a complex series of commands in PHP, and I'm not sure about exactly how to do it. We have two executables we need to work with:
generate
to create a fruit basket. This generates an XML file.peel
to peel a fruit by identifier. Generates a long string.
There are basically 5 steps:
First,
system("generate ... > fruits.xml", $returnValue);
.Next, load the resulting XML from
fruits.xml
file.Run the XPath query '//fruits/fruit/@id' on this file.
For each identifier in the results of this query, call
system("peel --fruit-id=$fruit_id > $fruit_id.txt")
.Concatenate all of the $fruit_id files into one large file, where each entry is separated with
***
.
I assume SimpleXMLElement is the way to go here for the XML querying in step 3, but I'm a little stumped about how to pull off the tasks in the other points. Any thoughts?