PHP application with Node.js

There are some cases where a PHP application also needs Node.js. It is for example the case if you use webpack to bundle the assets. For this reason, the PHP buildpack detects if you have a package.json file at the root of your repository and install Node.js if needed. Then the dependencies are installed, including those declared in devDependencies. This is the default behaviour as most of the time, dependencies to bundle the assets are declared as development dependencies.

If this is not the intended behaviour, or if you need to fine tune the Node.js installation, you better use the real Node.js buildpack. In this case, one should use multi buildpacks. Here is how to do that.

Add a file named .buildpacks at the root of your application containing (the order of the two lines is important):

Eventually, define the environment variable PHP_BUILDPACK_NO_NODE=true in your application.

With this setup, Scalingo will first execute the Node.js buildpack to execute yarn install and yarn build. Then the PHP buildpack is executed without the basic Node.js support it embeds.

Suggest edits

PHP application with Node.js

©2024 Scalingo