nikaia/php-node-bridge

从Php调用NodeJS脚本

v1.0.0 2022-11-16 10:40 UTC

This package is not auto-updated.

Last update: 2024-09-19 18:01:52 UTC


README

Latest Version on Packagist [Tests

从Php调用NodeJS脚本

安装

您可以通过composer安装此包

composer require nikaia/php-node-bridge

使用

该桥通过执行一个接受管道json任意数据并返回json响应的Node脚本来工作。

请参阅tests/_fixtures/ok.script.js以获取一个工作示例。

use Nikaia\NodeBridge\Bridge;

try {
    $response = Bridge::create()
        ->setNode('/usr/local/bin/node')        // the path to the node (You can omit if in system path)
        ->setScript('/path/to/your/script.js')  // the path to your script 
        ->pipe(['foo' => 'bar'])                // the data to pipe to the script
        ->run();
}
catch (BridgeException $e) {
    echo $e->getMessage();
}

var_dump($response->json());   // ['foo' => 'bar']
var_dump($response->output()); // the raw output of the script {"foo":"bar"}


更新日志

有关最近更改的更多信息,请参阅CHANGELOG

版本

此包使用semver版本。版本由standard-version节点包管理,并需要遵循conventionalcommit提交风格。

  1. 实现一个功能或修复等。
  2. 使用提交消息如fix: 修复问题feat: 实现功能 ...
  3. 或者在使用squash/closing PR时重写提交消息!
  4. 更新您本地的项目,切换到main分支
  5. 运行:composer release以生成更新日志并标记为新版本。
  6. 检查一切是否正常。
  7. 使用git push --follow-tags origin main推送标签

此存储库正在使用Semantic Pull Request bot强制执行常规提交消息和PR标题。

致谢

许可协议

MIT许可(MIT)。有关更多信息,请参阅许可文件