2017 © Pedro Peláez
 

composer-plugin component-installer

Allows installation of Components via Composer.

image

robloach/component-installer

Allows installation of Components via Composer.

  • Monday, May 14, 2018
  • by RobLoach
  • Repository
  • 20 Watchers
  • 256 Stars
  • 2,735,609 Installations
  • JavaScript
  • 152 Dependents
  • 14 Suggesters
  • 33 Forks
  • 30 Open issues
  • 25 Versions
  • 8 % Grown

The README.md

DEPRECATED

Component Installer has been deprecated. Use one of the following projects instead: - Composer Installers Extender - Asset Packagist - Composer Asset Plugin - Laravel Mix (Example: eventum/eventum#801 and eventum/eventum#812), (*1)

Example

composer require oomphinc/composer-installers-extender
  "extra": {
    "installer-types": ["component"],
    "installer-paths": {
      "components/{$name}/": ["type:component"]
    }
  }

Component Installer for Composer Build Status

Allows installation of Components via Composer., (*2)

Install

composer require robloach/component-installer

``` json { "require": { "robloach/component-installer": "*" } }, (*3)


## Usage To install a Component with Composer, add the Component to your *composer.json* `require` key. The following will install [jQuery](http://jquery.com) and [normalize.css](https://github.com/necolas/normalize.css):

composer require components/jquery composer require components/normalize.css, (*4)


``` json { "require": { "components/jquery": "2.*", "components/normalize.css": "3.*", "robloach/component-installer": "*" } }

Using the Component

The easiest approach is to use the Component statically. Just reference the Components manually using a script or link tag:, (*5)

``` html , (*6)


For complex projects, a [RequireJS](http://requirejs.org) configuration is available, which allows autoloading scripts only when needed. A *require.css* file is also compiled, including all Component stylesheets: ``` html <!DOCTYPE html> <html> <head> <link href="components/require.css" rel="stylesheet" type="text/css"> <script src="components/require.js"></script> </head> <body> <h1>jQuery+RequireJS Component Installer Sample Page</h1> <script> require(['jquery'], function($) { $('body').css('background-color', 'green'); }); </script> </body> </html>

Configuration

There are a number of ways to alter how Components are installed and used., (*7)

Installation Directory

It is possible to switch where Components are installed by changing the component-dir option in your root composer.json's config. The following will install jQuery to public/jquery rather than components/jquery:, (*8)

``` json { "require": { "components/jquery": "*" }, "config": { "component-dir": "public" } }, (*9)


Defaults to `components`. ### Base URL While `component-dir` depicts where the Components will be installed, `component-baseurl` tells RequireJS the base path that will use when attempting to load the scripts in the web browser. It is important to make sure the `component-baseurl` points to the `component-dir` when loaded externally. See more about [`baseUrl`](http://requirejs.org/docs/api.html#config-baseUrl) in the RequireJS documentation. ``` json { "require": { "components/jquery": "*" }, "config": { "component-dir": "public/assets", "component-baseurl": "/assets" } }

Defaults to components., (*10)

Assetic filters

``` json { "require": { "components/jquery": "*" }, "config": { "component-dir": "public/assets", "component-baseurl": "/assets", "component-scriptFilters": { "\Assetic\Filter\GoogleClosure\CompilerApiFilter": [] }, "component-styleFilters": { "\Assetic\Filter\CssImportFilter": [] } } }, (*11)


## Creating a Component To set up a Component to be installed with Component Installer, have it `require` the package *robloach/component-installer* and set the `type` to *component*, but it is not necessary: ``` json { "name": "components/bootstrap", "type": "component", "require": { "robloach/component-installer": "*" }, "extra": { "component": { "scripts": [ "js/bootstrap.js" ], "styles": [ "css/bootstrap.css" ], "files": [ "img/*.png", "js/bootstrap.min.js", "css/bootstrap.min.css" ] } } }
  • scripts - List of all the JavaScript files that will be concatenated together and processed when loading the Component.
  • styles - List of all the CSS files that should be concatenated together into the final require.css file.
  • files - Any additional file assets that should be copied into the Component directory.

Component Name

Components can provide their own Component name. The following will install jQuery to components/myownjquery rather than components/jquery:, (*12)

``` json { "name": "components/jquery", "type": "component", "extra": { "component": { "name": "myownjquery" } } }, (*13)


Defaults to the package name, without the vendor. ### RequireJS Configuration Components can alter how [RequireJS](http://requirejs.org) registers and interacts with them by changing some of the [configuration options](http://www.requirejs.org/docs/api.html#config): ``` json { "name": "components/backbone", "type": "component", "require": { "components/underscore": "*" }, "extra": { "component": { "shim": { "deps": ["underscore", "jquery"], "exports": "Backbone" }, "config": { "color": "blue" } } }, "config": { "component": { "waitSeconds": 5 } } }

Current available RequireJS options for individual packages include: * shim * config * Anything that's passed through config.component is sent to Require.js, (*14)

Packages Without Composer Support

Using repositories in composer.json allows use of Component Installer in packages that don't explicitly provide their own composer.json. In the following example, we define use of html5shiv:, (*15)

``` json { "require": { "afarkas/html5shiv": "3.6." }, "repositories": [ { "type": "package", "package": { "name": "afarkas/html5shiv", "type": "component", "version": "3.6.2", "dist": { "url": "https://github.com/aFarkas/html5shiv/archive/3.6.2.zip", "type": "zip" }, "source": { "url": "https://github.com/aFarkas/html5shiv.git", "type": "git", "reference": "3.6.2" }, "extra": { "component": { "scripts": [ "dist/html5shiv.js" ] } }, "require": { "robloach/component-installer": "" } } } ] }, (*16)


### Packages Without Component Support In *composer.json* Using [`extra`](https://getcomposer.org/doc/04-schema.md#extra) in *composer.json* allows use of Component Installer in packages that don't explicitly provide support for component, but do ship with their own *composer.json*. Using `extra` with packages that ship with Component Installer, will override component's settings for that package. ``` json { "require": { "datatables/datatables": "~1.10" }, "extra": { "component": { "datatables/datatables": { "scripts": [ "media/js/jquery.dataTables.js" ], "styles": [ "media/css/jquery.dataTables.css" ], "files": [ "media/js/jquery.dataTables.min.js", "media/css/jquery.dataTables.min.css", "media/images/*.png" ] } } } }

Not Invented Here

There are many other amazing projects from which Component Installer was inspired. It is encouraged to take a look at some of the other great package management systems: * npm * bower * component * Jam * volo * Ender * etc, (*17)

License

Component Installer is licensed under the MIT License - see LICENSE.md for details., (*18)

The Versions

14/05 2018

dev-master

9999999-dev

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

25/10 2017

dev-deprecated

dev-deprecated

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

10/08 2015

0.2.3

0.2.3.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

07/08 2015

0.2.2

0.2.2.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

18/06 2015

0.2.1

0.2.1.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

08/06 2015

0.2.0

0.2.0.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

29/05 2015

0.1.1

0.1.1.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

26/05 2015

0.1.0

0.1.0.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

05/05 2015

0.0.13-alpha2

0.0.13.0-alpha2

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

05/05 2015

0.0.13-alpha1

0.0.13.0-alpha1

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

01/09 2013

0.0.12

0.0.12.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

10/05 2013

0.0.11

0.0.11.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

10/05 2013

0.0.10

0.0.10.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

09/05 2013

0.0.9

0.0.9.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

09/05 2013

0.0.8

0.0.8.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

03/05 2013

0.0.7

0.0.7.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

22/04 2013

0.0.6

0.0.6.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

20/04 2013

0.0.5

0.0.5.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/04 2013

0.0.4

0.0.4.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

13/04 2013

0.0.3

0.0.3.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

13/04 2013

0.0.2

0.0.2.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

03/04 2013

0.0.1

0.0.1.0

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

 

The Development Requires

03/03 2013

0.0.1-alpha3

0.0.1.0-alpha3

Allows installation of Components via Composer.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

02/03 2013

0.0.1-alpha2

0.0.1.0-alpha2

Allows installation of Components via Composer.

  Sources   Download

MIT

02/03 2013

0.0.1-alpha1

0.0.1.0-alpha1

Allows installation of Components via Composer.

  Sources   Download

MIT