I'm trying to automate my deployment of hosting assets with Firebase using PHP. I'm trying to call 'firebase deploy' using shell_exec() in PHP, but so far I cannot seem to get it to work. No output is returned, and nothing gets written to a logfile if I pipe the output to one.
Is there any way to automate Firebase deployment using PHP?
(interesting note: since the 'firebase' command needs to be called from within the actual public directory that will be pushed, I'm guessing I need to call '/usr/local/bin/firebase deploy'
and pass in the parameters of the Firebase directory that I want to push using the -p
flag. Is this correct or can I omit -p
entirely?)
Firebase deploy works fine on the command line when I type it in manually.
Please help!
After contacting Firebase, one of their awesome devs there helped me out and he suggested this, which worked for me:
<!DOCTYPE html>
<html>
<body>
<?php
exec('PATH=/usr/local/bin:$PATH && firebase deploy', $output);
print_r($output);
?>
</body>
</html>
So thanks to Firebase support, I got this working. It basically has to do with Apache and web sessions. The $PATH was needed:
The problem has to do with the web server session. When running those commands, he found that the output is "command not found". This error is returned when the $PATH doesn't contain the path to the desired commands (in this case firebase and node).
To fix this, he had to add this path to $PATH in the current session, so it is possible to call 'firebase deploy'.
Thanks again, Firebase!