abhishek6262/nodephp

A PHP wrapper around Node JS.

v0.2.1 2019-04-12 10:31 UTC

This package is auto-updated.

Last update: 2024-04-12 21:25:45 UTC


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.

Read Blog Post.

Installation

NodePHP is available on Packagist and installation via Composer is the recommended way to install NodePHP.

composer require abhishek6262/nodephp

Examples

require_once "vendor/autoload.php";

// $environment = new \abhishek6262\NodePHP\System\Environment('projectRootPath', 'binDirectoryPath');
$environment = new \abhishek6262\NodePHP\System\Environment(__DIR__);

$npm = new \abhishek6262\NodePHP\NPM($environment);

if (! $npm->exists()) {
    $npm->install();
}

if ($npm->packagesExists() && ! $npm->packagesInstalled()) {
    $response = $npm->installPackages();
    
    if ($response->statusCode() == '0') {
        echo "Packages successfully installed.";
    } else {
        echo "Failed to install the packages.";
    }
    
    print_r($response->output());
}

Credits

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionality. I will appreciate that a lot. Also please add your name to the credits.

Kindly follow me on twitter!

Support

Moreover, To keep this and my other open source projects ongoing You can also support me on Patreon by clicking on the button below.

68747470733a2f2f63352e70617472656f6e2e636f6d2f65787465726e616c2f6c6f676f2f6265636f6d655f615f706174726f6e5f627574746f6e2e706e67

License

The MIT License (MIT). Please see License File for more information.