Use proc_open which allows you to create a custom pipe to feed data (the user password) when prompted. See the comments at the link for ways to create a custom password pipe.
Update, since you're not able to read.
Snippet from comment by snowleopard at amused dot NOSPAMPLEASE dot com dot au at 05-Jun-2008 02:46 at the previously twice mentioned link. You just need to apply this to your own situation.
// Set up the descriptors
$Descriptors = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w"),
3 => array("pipe", "r") // This is the pipe we can feed the password into
);
// Build the command line and start the process
$CommandLine = $GPGPath . ' --homedir ' . $HomeDir . ' --quiet --batch --local-user "' . $Identity . '" --passphrase-fd 3 --decrypt -';
$ProcessHandle = proc_open( $CommandLine, $Descriptors, $Pipes);
if(is_resource($ProcessHandle)) {
// Push passphrase to custom pipe
fwrite($Pipes[3], $PassPhrase);
fclose($Pipes[3]);