Permalink
Browse files

Re-implement ComponentInstaller as a composer plugin

This patch re-implements `ComposerInstaller` as a [composer plugin](https://getcomposer.org/doc/articles/plugins.md).
Doing so simplifies installation (just install it via Composer!), and simplifies
fundamental operations such as caching injectors between packages.

This also means that the PHAR automation is no longer necessary, allowing
removal of a ton of code.
  • Loading branch information...
weierophinney committed Mar 14, 2016
1 parent f9fecce commit ad53d2f4185082498bf261c24dfd3c56f2872637
View
@@ -13,17 +13,13 @@ matrix:
env:
- EXECUTE_CS_CHECK=true
- php: 5.6
env:
- EXECUTE_DEPLOYMENT=true
- php: 7
- php: hhvm
allow_failures:
- php: hhvm
before_install:
- openssl aes-256-cbc -K $encrypted_bdfd67bd0d47_key -iv $encrypted_bdfd67bd0d47_iv -in .travis/secrets.tar.enc -out .travis/secrets.tar -d
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini ||
return 0 ; fi
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- composer self-update
install:
@@ -38,9 +34,5 @@ script:
after_script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer coveralls ; fi
after_success:
- if [[ $EXECUTE_DEPLOYMENT == 'true' && $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then composer install --no-dev ; fi
- if [[ $EXECUTE_DEPLOYMENT == 'true' && $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then ./bin/deploy.sh ; fi
notifications:
email: true
View
@@ -1,60 +1,63 @@
# Component Installer for Zend Framework 3 Applications
This repository contains the class `Zend\ComponentInstaller\ComponentInstaller`,
This repository contains the Composer plugin class `Zend\ComponentInstaller\ComponentInstaller`,
which provides Composer event hooks for the events:
- post-package-install
- post-package-uninstall
In order to utilize these, you will need to add the `ComponentInstaller`
classfile to your project, make it autoloadable, and then add its relevant
static methods as scripts for the above events.
## Via Composer global install
This package provides two ways for doing that: as a global composer utility, or
via a downloadable, self-updateable PHAR.
## Via Composer Global Install
To install the utility via Composer:
To install the utility for use with all projects you use:
```bash
$ composer global require zendframework/zend-component-installer
```
Once installed, assuming that the Composer `bin/` directory is on your `$PATH`,
you can then execute the following:
## Per project installation
To install the utility for use with a specific project already managed by
composer:
```bash
$ zend-component-installer install <path>
$ composer require zendframework/zend-component-installer
```
where `<path>` is the path to a project in which you want to install the
component installer tools. If `<path>` is omitted, the utility assumes the
current working directory should be used.
## Via PHAR
The PHAR file is downloadable at:
- https://zendframework.github.io/zend-component-installer/zend-component-installer.phar
## Writing packages that utilize the installer
The public key for verifying the package is at:
Packages can opt-in to the workflow from zend-component-installer by defining
one or more of the following keys under the `extra.zf` configuration in their
`composer.json` file:
- https://zendframework.github.io/zend-component-installer/zend-component-installer.phar.pubkey
You will need to download both files, to the same directory, for the utility to
work; additionally, the name of the key must not be changed.. Once downloaded,
make the the PHAR file executable.
Once installed, you can then execute the following:
```bash
$ zend-component-installer.phar install <path>
```json
"extra": {
"zf": {
"component": "Component\\Namespace",
"config-provider": "Classname\\For\\ConfigProvider",
"module": "Module\\Namespace"
}
}
```
where `<path>` is the path to a project in which you want to install the
component installer tools. If `<path>` is omitted, the utility assumes the
current working directory should be used.
The PHAR file is self-updateable via the `self-update` command; this feature
requires PHP 5.6, however, due to SSL/TLS negotiation requirements.
- A **component** is for use specifically with zend-mvc + zend-modulemanager;
a `Module` class **must** be present in the namespace associated with it.
The setting indicates a low-level component that should be injected to the top
of the modules list of one of:
- `config/application.config.php`
- `config/modules.config.php`
- `config/development.config.php`
- A **module** is for use specifically with zend-mvc + zend-modulemanager;
a `Module` class **must** be present in the namespace associated with it.
The setting indicates a userland or third-party module that should be injected
to the bottom of the modules list of one of:
- `config/application.config.php`
- `config/modules.config.php`
- `config/development.config.php`
- A **config-provider** is for use with applications that utilize
[expressive-config-manager](https://github.com/mtymek/expressive-config-manager)
(which may or may not be Expressive applications). The class listed must be an
invokable that returns an array of configuration, and will be injected at the
top of:
- `config/config.php`
View

This file was deleted.

Oops, something went wrong.
View
@@ -1,12 +1,17 @@
{
"name": "zendframework/zend-component-installer",
"description": "Composer scripts for automating component registration in zend-mvc applications",
"description": "Composer plugin for automating component registration in zend-mvc and Expressive applications",
"type": "composer-plugin",
"license": "BSD-3-Clause",
"require": {
"php": "^5.5 || ^7.0",
"zendframework/zend-console": "^2.5",
"zfcampus/zf-console": "^1.0",
"padraic/phar-updater": "^1.0"
"composer-plugin-api": "^1.0"
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
},
"class": "Zend\\ComponentInstaller\\ComponentInstaller"
},
"require-dev": {
"composer/composer": ">=1.0.0-alpha10",
@@ -25,10 +30,6 @@
"ZendTest\\ComponentInstaller\\": "test/"
}
},
"bin": [
"bin/component-installer",
"bin/component-installer.bat"
],
"scripts": {
"check": [
"@cs",
View

This file was deleted.

Oops, something went wrong.
View
@@ -18,7 +18,5 @@
<!-- Paths to check -->
<file>src</file>
<file>test</file>
<exclude-pattern>test/TestAsset/application*.config.php</exclude-pattern>
<exclude-pattern>test/TestAsset/functions.php</exclude-pattern>
<exclude-pattern>test/Command/TestAsset/functions.php</exclude-pattern>
<exclude-pattern>test/Injector/TestAsset/*.php</exclude-pattern>
</ruleset>
View
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="test/bootstrap.php"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Zend\\Expressive Tests">
<testsuite name="Zend\\ComponentInstaller Tests">
<directory>./test</directory>
</testsuite>
</testsuites>
Oops, something went wrong.

0 comments on commit ad53d2f

Please sign in to comment.