views:

20

answers:

0

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:

  1. First, system("generate ... > fruits.xml", $returnValue);.

  2. Next, load the resulting XML from fruits.xml file.

  3. Run the XPath query '//fruits/fruit/@id' on this file.

  4. For each identifier in the results of this query, call system("peel --fruit-id=$fruit_id > $fruit_id.txt").

  5. 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?