How can I use PHP libraries from composer when I start using Node.js?

View other answers to this thread
Start a personal dev blog on your domain for free and grow your readership.

3.4K+ developers have started their personal blogs on Hashnode in the last one month.

Write in Markdown · Publish articles on custom domain · Gain readership on day zero · Automatic GitHub backup and more

Shreyansh Pandey's photo

Hey, sounds like a pretty interesting question. Now, there are two options for you: one might sound intuitive and the other might sound a little obvious.

So, the first option you have is to turn them into microservices. If it's your own customer composer library, you can deploy it as a microservice and use it with whatever application you want. The con of this approach is the fact that you can break dependant applications if the microservices backend fails.

The second one is that almost everything for PHP is available for Node.js with minor or no changes. You can try going that way and if that doesn't work out, you might have to re-write them. This really gives a nice performance boost as you'll write some code in the language which the engine can run.

Another, but not-so-favoured method will be to to use php-fpm. Go to this link to see how.

If you need help in conversion or with anything else, feel free to drop me a line! :)