Component Installer

A (prototype) component installer for ZF3 components.

Why?

We're planning on reducing the required components for the MVC and framework. Currently in v2, however, zend-mvc provides copious amounts of integrations with other components; removing them as dependencies means their factories, plugin managers, and event listeners will not be wired automatically. One proposed solution is to provide each component with a Module class that could provide those; however, one issue with that approach is ensuring that the components are then added to the list of enabled modules.

The approach this package takes is to provide Composer event hooks that will update the enabled module list when a package providing a module is installed or uninstalled. However, Composer has a few limitations with regards to such hook scripts:

These limitations are easily accommodated for new projects, as we can include them in project skeletons. However, for those migrating to ZF3, we want to provide a mechanism for adding the scripts.

The solution presented here is to provide a utility that will will copy the classfiles for the scripts into your project, and then manipulate the composer.json to add autoload rules for them, and to add entries for the event hook scripts.

You have two options: using a downloadable, self-updateable PHAR, or installation as a global Composer package.


Get the PHAR

You'll need to download both files, and they will need to reside together.

Once downloaded, make the PHAR executable, and execute zend-component-installer.phar help to verify that it works.

Using the PHAR


$ zend-component-installer.phar install
# Or specify a path to a project
$ zend-component-installer.phar install /path/to/my/project
    

Once installed, whenever your install a component that implements a module, it will update the config/application.config.php file to add the component to the module list. Components are always added to the top of the list, to ensure that your own modules can override any settings they introduce.

Keeping up-to-date

Periodically, we may make changes to the tool. To update, you can use the self-update command:


$ zend-component-installer.phar self-update
    

Two notes on this command:

Rolling back

When using the PHAR, you can also rollback to a previously installed version, if you have kept the zend-component-installer-old.phar file:


$ zend-component-installer.phar rollback
    

Global Composer Installation

You can also install the utility as a global Composer package:


$ composer global require zendframework/zend-component-installer
    

This will install the package globally. In order to use it, the $COMPOSER_HOME/bin directory must be in your user's $PATH. From there, invocation is:


$ zend-component-installer installer []
    

Keeping up-to-date

To keep your utility up-to-date, periodically perform the following:


$ composer global update zendframework/zend-component-installer
    

Defining a component that implements a module

There are two things you must do to have your package opt-in to this workflow:

Component modules are placed at the top of the module list, so that userland modules may override the defaults they provide.

Defining a userland module

There are two things you must do to have your package opt-in to this workflow:

Userland modules are placed at the bottom of the module list, so that their settings may override component settings.