decodelabs / overpass
Simple node.js bridge
Installs: 1 593
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.4
- decodelabs/archetype: ^0.3.9
- decodelabs/atlas: ^0.12
- decodelabs/exceptional: ^0.5
- decodelabs/monarch: ^0.1.2
- decodelabs/systemic: ^0.11.6
Requires (Dev)
README
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.