Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku PHP and Node.js in the same app

Tags:

I'm using a Node package called exec-php to execute PHP functions within Node.js app.

I would like to push that app to Heroku, but I'm wondering how to make that, and how that would be in the PHP bin locally.

I'm using /Applications/MAMP/bin/php/php7.0.0/bin/php. What would be the path to PHP bin in Heroku?

I tested vendor/bin/heroku-php-apache2 but it doesn't work, so what would be the path to PHP binary in Heroku?

like image 365
Stranger B. Avatar asked May 29 '16 00:05

Stranger B.


People also ask

Can you use PHP and node js together?

Yes, and yes. Node and Apache / PHP can co-exist on a single server.

Can I run PHP on Heroku?

Heroku PHP Support will be applied to applications only when the application has a file named composer. json in the root directory. Even if an application has no Composer dependencies, it must include an empty composer. json in order to be recognized as a PHP application.

Does heroku support node JS?

Heroku Node. js support will only be applied when the application has a package. json file in the root directory.

Is PHP better or node JS?

Due to the V8 engine, asynchronous execution, and real-time server interaction, Node. js offers a better execution speed and certainly outperforms PHP.


1 Answers

You'll need to inform the build API that you'd like to use multiple buildpacks. Try:

$ heroku buildpacks:clear $ heroku buildpacks:add heroku/php $ heroku buildpacks:add heroku/nodejs 

Then you can inspect the compiled slug via heroku run bash to verify that the bins are where you expect them to be.

like image 76
RangerRanger Avatar answered Sep 21 '22 17:09

RangerRanger