After all this, the OP remains unenlightened. This is just a waste of time. "You are doing this wrong." "There are existing tools that do what your client wants." "A command line tool is not the same as the php library." are all met with "I don't want to learn, just tell me what isn't working." Too bad.