decodelabs/overpass

Simple node.js bridge

v0.3.0 2025-04-30 18:10 UTC

This package is auto-updated.

Last update: 2025-05-01 09:59:35 UTC


README

PHP from Packagist Latest Version Total Downloads GitHub Workflow Status PHPStan License

Simple node.js bridge for PHP

Overpass provides a simple interface for installing dependencies and interacting with native node.js scripts.

Installation

composer require decodelabs/overpass

Usage

Load a project to work from:

use DecodeLabs\Overpass\Project;

$project = new Project('path/to/project/');

If no path is specified, the current working directory will be used. Overpass will search back up the file tree for the nearest package.json.

use DecodeLabs\Overpass;

echo $project->rootDir; // Parent or current dir containing package.json
echo $project->packageFile; // Location  of package.json

$project->run('myfile.js'); // node myfile.js
$project->runScript('my-script'); // npm run my-script
$project->runExecutable('vite', 'build'); // vite build
$project->runPackage('create-react-app'); // npx create-react-app

$project->install('package1', 'package2'); // npm install package1 package2
$project->installDev('package1', 'package2'); // npm install package1 package2 --save-dev

Bridging

Overpass offers a simple Bridge system to allow you to define custom javascript, pass arguments to it, and consume the result via node.

// myfile.js
module.exports = function(input) {
    return 'hello ' + input;
}
$result = $project->bridge('myfile.js', 'world'); // 'hello world'

Licensing

Overpass is licensed under the MIT License. See LICENSE for the full license text.