PHPackages                             robloach/component-installer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. robloach/component-installer

Abandoned → [oomphinc/composer-installers-extender](/?search=oomphinc%2Fcomposer-installers-extender)Composer-plugin[Utility &amp; Helpers](/categories/utility)

robloach/component-installer
============================

Allows installation of Components via Composer.

0.2.3(10y ago)2927.8M↓31.2%33[30 issues](https://github.com/RobLoach/component-installer/issues)20MITJavaScriptPHP &gt;=5.3.2

Since Mar 2Pushed 6y ago18 watchersCompare

[ Source](https://github.com/RobLoach/component-installer)[ Packagist](https://packagist.org/packages/robloach/component-installer)[ RSS](/packages/robloach-component-installer/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (4)Versions (25)Used By (20)

DEPRECATED
==========

[](#deprecated)

Component Installer has been deprecated. Use one of the following projects instead:

- [Composer Installers Extender](https://github.com/oomphinc/composer-installers-extender)
- [Asset Packagist](https://asset-packagist.org)
- [Composer Asset Plugin](https://github.com/fxpio/composer-asset-plugin)
- [Laravel Mix](https://laravel.com/docs/5.8/mix) (Example: [eventum/eventum#801](https://github.com/eventum/eventum/pull/801) and [eventum/eventum#812](https://github.com/eventum/eventum/pull/812))

Example
-------

[](#example)

```
composer require oomphinc/composer-installers-extender

```

```
  "extra": {
    "installer-types": ["component"],
    "installer-paths": {
      "components/{$name}/": ["type:component"]
    }
  }

```

Component Installer for [Composer](http://getcomposer.org) [![Build Status](https://camo.githubusercontent.com/a4e036227375e5e2f6856e9ee8a3f143479257170c737bea4755d3600cf7a752/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f526f624c6f6163682f636f6d706f6e656e742d696e7374616c6c65722e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/RobLoach/component-installer)
===========================================================================================================================================================================================================================================================================================================================================================================================

[](#component-installer-for-composer-)

Allows installation of Components via [Composer](http://getcomposer.org).

Install
-------

[](#install)

```
composer require robloach/component-installer

```

```
{
    "require": {
        "robloach/component-installer": "*"
    }
}
```

Usage
-----

[](#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

```

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

### Using the Component

[](#using-the-component)

The easiest approach is to use the Component statically. Just reference the Components manually using a `script` or `link` tag:

```

```

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:

```
>

        jQuery+RequireJS Component Installer Sample Page

          require(['jquery'], function($) {
            $('body').css('background-color', 'green');
          });

```

Configuration
-------------

[](#configuration)

There are a number of ways to alter how Components are installed and used.

### Installation Directory

[](#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*:

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

Defaults to `components`.

### Base URL

[](#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.

```
{
    "require": {
        "components/jquery": "*"
    },
    "config": {
        "component-dir": "public/assets",
        "component-baseurl": "/assets"
    }
}
```

Defaults to `components`.

### Assetic filters

[](#assetic-filters)

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

Creating a Component
--------------------

[](#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:

```
{
    "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

[](#component-name)

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

```
{
    "name": "components/jquery",
    "type": "component",
    "extra": {
        "component": {
            "name": "myownjquery"
        }
    }
}
```

Defaults to the package name, without the vendor.

### RequireJS Configuration

[](#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):

```
{
    "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`](http://www.requirejs.org/docs/api.html#config-shim)
- [`config`](http://www.requirejs.org/docs/api.html#config-moduleconfig)
- Anything that's passed through `config.component` is sent to Require.js

### Packages Without Composer Support

[](#packages-without-composer-support)

Using [`repositories`](http://getcomposer.org/doc/05-repositories.md#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](https://github.com/aFarkas/html5shiv):

```
{
    "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": "*"
                }
            }
        }
    ]
}
```

### Packages Without Component Support In *composer.json*

[](#packages-without-component-support-in-composerjson)

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.

```
{
    "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
-----------------

[](#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](http://github.com/wilmoore/frontend-packagers):

- [npm](http://npmjs.org)
- [bower](http://bower.io/)
- [component](http://github.com/component/component)
- [Jam](http://jamjs.org)
- [volo](http://volojs.org)
- [Ender](http://ender.jit.su)
- etc

License
-------

[](#license)

Component Installer is licensed under the MIT License - see LICENSE.md for details.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity61

Solid adoption and visibility

Community43

Growing community involvement

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~40 days

Recently: every ~18 days

Total

23

Last Release

3956d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25086?v=4)[Rob Loach](/maintainers/RobLoach)[@RobLoach](https://github.com/RobLoach)

---

Top Contributors

[![RobLoach](https://avatars.githubusercontent.com/u/25086?v=4)](https://github.com/RobLoach "RobLoach (114 commits)")[![Moro4125](https://avatars.githubusercontent.com/u/8122412?v=4)](https://github.com/Moro4125 "Moro4125 (3 commits)")[![InconclusiveImpurity](https://avatars.githubusercontent.com/u/18524348?v=4)](https://github.com/InconclusiveImpurity "InconclusiveImpurity (2 commits)")[![glensc](https://avatars.githubusercontent.com/u/199095?v=4)](https://github.com/glensc "glensc (2 commits)")[![hjr3](https://avatars.githubusercontent.com/u/33318?v=4)](https://github.com/hjr3 "hjr3 (2 commits)")[![cordoval](https://avatars.githubusercontent.com/u/328359?v=4)](https://github.com/cordoval "cordoval (2 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![scor](https://avatars.githubusercontent.com/u/77741?v=4)](https://github.com/scor "scor (1 commits)")[![aurelijusrozenas](https://avatars.githubusercontent.com/u/3273544?v=4)](https://github.com/aurelijusrozenas "aurelijusrozenas (1 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (1 commits)")[![holtkamp](https://avatars.githubusercontent.com/u/776405?v=4)](https://github.com/holtkamp "holtkamp (1 commits)")[![jijoel](https://avatars.githubusercontent.com/u/3487641?v=4)](https://github.com/jijoel "jijoel (1 commits)")[![kelunik](https://avatars.githubusercontent.com/u/2743004?v=4)](https://github.com/kelunik "kelunik (1 commits)")[![marclaporte](https://avatars.githubusercontent.com/u/1004261?v=4)](https://github.com/marclaporte "marclaporte (1 commits)")[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/robloach-component-installer/health.svg)

```
[![Health](https://phpackages.com/badges/robloach-component-installer/health.svg)](https://phpackages.com/packages/robloach-component-installer)
```

###  Alternatives

[symfony/runtime

Enables decoupling PHP applications from global state

74694.9M933](/packages/symfony-runtime)[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k40.0M2.6k](/packages/ergebnis-composer-normalize)[drupal/core-composer-scaffold

A flexible Composer project scaffold builder.

5344.1M525](/packages/drupal-core-composer-scaffold)[drupal/core-project-message

Adds a message after Composer installation.

2124.0M192](/packages/drupal-core-project-message)[sandersander/composer-link

Adds ability to link local packages for development with composer

98441.4k](/packages/sandersander-composer-link)[phpro/grumphp-shim

GrumPHP Phar distribution

284.6M333](/packages/phpro-grumphp-shim)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
