yama/nodeinphp
最新稳定版本:0.5
Composer 安装命令:
composer require yama/nodeinphp
包简介
A PHP wrapper around Node JS.
README 文档
README
The PHP instance of Project-Level Node JS.
This library allows you to install node js on your project making it possible for you to use node js even when it is not installed in the system. Moreover, You can consume the power of node js, npm and npx commands with ease using a php class.
This project is a development of the THIS project
Installation
NodePHP is available on Packagist and installation via Composer is the recommended way to install NodePHP.
composer require yama/nodeinphp
Examples
<?php
require_once "vendor/autoload.php";
$node = new \Yama\NodeInPhp\Node(__DIR__);
$node->nvmUse('16.20.0');
if ($node->packagesExists() && !$node->packagesInstalled()) {
$response = $node->installPackages();
if ($response->statusCode() == '0') {
echo "Packages successfully installed.";
} else {
echo "Failed to install the packages.";
}
print_r($response->output());
}
$response = $node->node('-v');
$message = 'Node Version: ' . PHP_EOL;
foreach ($response->output() as $line) {
$message .= $line . PHP_EOL;
}
echo $message . PHP_EOL;
$response = $node->npm('-v');
$message = 'NPM Version: ' . PHP_EOL;
foreach ($response->output() as $line) {
$message .= $line . PHP_EOL;
}
echo $message . PHP_EOL;
$response = $node->npx('-v');
$message = 'NPX Version: ' . PHP_EOL;
foreach ($response->output() as $line) {
$message .= $line . PHP_EOL;
}
echo $message . PHP_EOL;
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-13