decodelabs / overpass
Simple node.js bridge
Installs: 1 264
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- decodelabs/atlas: ^0.12
- decodelabs/exceptional: ^0.4
- decodelabs/systemic: ^0.11.6
- decodelabs/terminus: ^0.10
- decodelabs/veneer: ^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.
Get news and updates on the DecodeLabs blog.
Installation
composer require decodelabs/overpass
Usage
Load a context to work from:
use DecodeLabs\Overpass\Context; $context = new Context('path/to/project/');
Or use the Overpass
Veneer frontage to work from cwd()
.
Overpass will search back up the file tree for the nearest package.json.
use DecodeLabs\Overpass; echo Overpass::$runDir; // Working directory echo Overpass::$rootDir; // Parent or current dir containing package.json echo Overpass::$packageFile; // Location of package.json Overpass::run('myfile.js'); // node myfile.js Overpass::runScript('my-script'); // npm run my-script Overpass::install('package1', 'package2'); // npm install package1 package2 Overpass::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; }
use DecodeLabs\Overpass; $result = Overpass::bridge('myfile.js', 'world'); // 'hello world'
Licensing
Overpass is licensed under the MIT License. See LICENSE for the full license text.