Code Monkey home page Code Monkey logo

binary-nodejs's Introduction

NodeJS installer for Composer

This is an installer that will download NodeJS and NPM and install them in your Composer dependencies. Installation is skipped if NodeJS is already available on your machine.

More information on recent changes HERE.

Vaimo Modifications

  • Change the order of Composer events to allow the module to be used together with foxy/foxy
  • Use Composer downloader/unpacker through creating virtual package for the node
  • Default behaviour changed to always prefer to install Local version except in situations where user explicitly asks for Global one (mouf/nodejs/useGlobal)

Why?

NodeJS is increasingly becoming a part of the tool-chain of modern web developers. Tools like Bower, Grunt, Gulp... are used everyday to build applications. For the PHP developer, this means PHP projects have build dependencies on NodeJS or Bower / NPM packages. The NodeJS-installer attempts to bridge the gap between NodeJS and PHP by making NodeJS easily installable as a Composer dependency.

Building on this package, other packages like koala-framework/composer-extra-assets can be used to automatically fetch Bower / NPM packages, run Gulp / Grunt tasks, etc...

How does it work?

Simply include this package in your composer.json requirements:

{
    "require": {
        "mouf/nodejs-installer": "~1.0"
    }
}

By default, if NodeJS is not available on your computer, it will be downloaded and installed in vendor/nodejs/nodejs.

You should access NodeJS and NPM using the scripts created into the vendor/bin directory:

  • vendor/bin/node (vendor/bin/node.bat on Windows)
  • vendor/bin/npm (vendor/bin/npm.bat on Windows)

Options

A number of options are available to customize NodeJS installation:

{
    "require": {
        "mouf/nodejs-installer": "~1.0"
    },
    "extra": {
        "mouf": {
            "nodejs": {
                "version": "~0.12",
                "targetDir": "vendor/nodejs/nodejs",
                "forceLocal": false
            }
        }
    }
}

Available options:

  • version: This is the version number of NodeJS that will be downloaded and installed. You can specify version constraints in the usual Composer format (for instance "~0.12" or ">0.11").
    Default value: * The latest stable version of NodeJS is installed by default.
  • targetDir: The target directory NodeJS will be installed in. Relative to project root.
    This option is only available in the root package.
    Default value: vendor/nodejs/nodejs
  • forceLocal (boolean): If set to true, NodeJS will always be downloaded and installed locally, even if NodeJS is already available on your computer.
    This option is only available in the root package.
    Default value: false
  • includeBinInPath (boolean): After the plugin is run in Composer, the vendor/bin directory can optionally be added to the PATH. This is useful if other plugins rely on "node" or "npm" being available globally on the computer. Using this option, these other plugins will automatically find the node/npm version that has been downloaded. Please note that the PATH is only set for the duration of the Composer script. Your global environment is not impacted by this option.
    This option is only available in the root package.
    Default value: false

Custom script

The installer listens to the following composer scripts to be launched:

{
    "post-install-cmd": {
        // ...
    },
    "post-update-cmd": {
        // ...
    }
}

If you need to launch the installer manually, you can run the following command:

$ composer run-script download-nodejs

binary-nodejs's People

Contributors

dbu avatar drpayyne avatar elvinristi avatar itmo-urir avatar kaufmo avatar merwan avatar moufmouf avatar nsams avatar pedrotroller avatar seldaek avatar xhuberty avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

drpayyne thewhisp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.