too long

The title is a little vague, I believe. But my english's not good, so I'm lacking of an better one.

I'm currenty writing a tool that also executes the composer.phar from the source code.

So when installing some stuff with composer.phar it sometimes asks questions and wants additional input, like desired format or simples Y/N questions.

When I use exec() it seems that it's not possible to react to those questions.

So I wondered how I can achieve this with PHP.

Any ideas?

Update To show an simple example, I do this:

exec("php /Users/johannesklauss/Development/web/composer.phar create-project symfony/framework-standard-edition /Users/johannesklauss/Development/web/Symfony 2.1.x-dev");

Problem here is that the composer at the and asks if it should keep the version control history:

Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]?

So I need to type in y or n to the console. But that's not possible with exec. So I need some interactive mode or what.

One word of caution: look for flags you can send to the initial command to "auto answer". You have no real guarantees about what question composer.phar will ask or the order it will ask them. It should be considered a "hack" and the normal reaction in our brains should apply with all it's caution and context, etc...

Anyway, I think what you'll need is proc_open(), which let's you start a process and have access to the stdin and stdout for it. See the Example #1 code on that doc page, it's very close to what you likely need.

Once you have access to the stdin/stdout resources for the process, you can read from/write to them however you like. The good news is that this will let you "read" the prompt and at LEAST double-check that it's asking what you expect it to be asking (and e.g. throw an exception if you don't recognize the prompt)