PHPackages                             lifespikes/php-node - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lifespikes/php-node

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lifespikes/php-node
===================

Spawn and manage node instances from PHP

1.0.0(4y ago)224.5k↓11.1%MITPHP

Since Mar 14Pushed 4y ago2 watchersCompare

[ Source](https://github.com/lifespikes/php-node)[ Packagist](https://packagist.org/packages/lifespikes/php-node)[ RSS](/packages/lifespikes-php-node/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

PHP Node
========

[](#php-node)

Simple library for executing short-lived NodeJS processes from PHP.

Hi Packagist :)

### Who is this for?

[](#who-is-this-for)

Every language and platform has their pros and cons, for us one of the biggest benefits of JavaScript is being able to whip up programs in the span of a few minutes.

This package is for developers who want a simple, object-oriented, library to integrate microservices written in Node in their PHP apps.

### All this for a process manager?

[](#all-this-for-a-process-manager)

PHP Node is a library we built to leverage power from multiple languages different members of our team specialize in and their awesome ecosystems. Naturally we want these integrations to be as seamless as possible with the rest of our code, but we also don't want to make anything more complicated than it needs to be.

Instead of implementing separate APIs for each service using let's say a SOAP or REST interface using Express, or deploying these services as docker containers, PHP Node helps us:

- Execute scripts using a simple one-line syntax
- Mitigate disconnects in error reporting
- Quickly deploy new microservices with minimal setup
- Test integrations by asserting `FinishedProcess` properties
- Send and receive information without using arguments
- Easily determine error reasons, exit status, and other details

### Examples

[](#examples)

Using PHP Node is pretty straight forward.

The very first step is going to be making sure you have **NodeJS** installed on your machine. The version you run is up to you. Then, make sure the path to Node is present in your `PATH`, or set as a `NODE_BINARY` environment variable.

Now make sure your script is accessible by your web server or PHP process owner.

Lastly, make sure to expect input on your script by receiving it using `stdin`, instead of `argv`. We opted for using the stream route to allow us to broadcast reliable and larger chunks of data.

(*This library is pretty awesome at this: *)

Then, just run it. In this example we're using a microservice to take a screenshot of a website:

```
