Skip to content
The PHP instance of Project-Level Node JS.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
composer.json
renovate.json

README.md

NodePHP

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.

License

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

You can’t perform that action at this time.