PHPackages                             consolidation/bootstrap - 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. [Framework](/categories/framework)
4. /
5. consolidation/bootstrap

ActiveLibrary[Framework](/categories/framework)

consolidation/bootstrap
=======================

Locate and bootstrap components needed to run code from a framework.

461[1 issues](https://github.com/consolidation/bootstrap/issues)[1 PRs](https://github.com/consolidation/bootstrap/pulls)PHP

Since Apr 6Pushed 5y ago2 watchersCompare

[ Source](https://github.com/consolidation/bootstrap)[ Packagist](https://packagist.org/packages/consolidation/bootstrap)[ RSS](/packages/consolidation-bootstrap/feed)WikiDiscussions main Synced 2mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Consolidation\\Bootstrap
========================

[](#consolidationbootstrap)

Locate and bootstrap components needed to run code from a framework.

[![Travis CI](https://camo.githubusercontent.com/a21a751c3b32fc5fa4359e314e86fc778346afa3a9e93ac9ee415675eba8ea34/68747470733a2f2f7472617669732d63692e6f72672f636f6e736f6c69646174696f6e2f626f6f7473747261702e7376673f6272616e63683d6d61696e)](https://travis-ci.org/consolidation/bootstrap)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/02c452625c3bd23101e84351e8d9653d9843f537140cfbbb49d1129174b227e9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f6e736f6c69646174696f6e2f626f6f7473747261702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/consolidation/bootstrap/?branch=main)[![Coverage Status](https://camo.githubusercontent.com/2760cb8607fec08b339601f3bb506c681ef2e733f00920b98cfb7ef89731f378/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f636f6e736f6c69646174696f6e2f626f6f7473747261702f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/consolidation/bootstrap?branch=main)[![License](https://camo.githubusercontent.com/eff522098312ba7bc05f98e5fddd35194e198ee1bead6fd02c2a1fcb21eb6814/68747470733a2f2f706f7365722e707567782e6f72672f636f6e736f6c69646174696f6e2f626f6f7473747261702f6c6963656e7365)](https://packagist.org/packages/consolidation/bootstrap)

This component is designed to be called from a commandline application, such as [Drush](https://github.com/drush-ops/drush) or [Drupal Console](https://github.com/hechoendrupal/DrupalConsole). It is the responsibility of the application to provide basic information about the operating environment, such as:

- The location of the application's code.
- The location of the framework selected by the user, if any.
- Other user-supplied options, as needed (e.g. which specific site in a multi-site configuration should be selected).

Given this information, this component is responsible for:

- Locating code assets.
    - Command classes in the commandline application.
    - Global plugin command classes in different locations (e.g. in user's home directory).
    - Site-specific plugin command classes stored in the framework.
    - Module and theme-provided command classes.
- Identifying the specific framework and major version that the user selected.
- Providing a mechanism for bootstrapping the framework.
    - Bootstrapping can be done up to a level that provides services needed by the command:
        - Access to the code in the selected framework (include the autoloader).
        - Access to the settings for the specific site (include settings.php or equivalent).
        - Access to the site's database.
        - Access to the site's configuration.
        - Access to the full site's runtime.
        - Access to a logged-in user.
    - Each service level defines which other services are needed, and all are bootstrapped in order.
    - Bootstrap classes for specific frameworks can add more services.
- Provide a mechanism for filtering usable commands.
    - Some commands may require APIs from a specific commandline application.
    - Some commands may require APIs from a specific framework.
    - Some commands may require APIs from specific Composer libraries, which may be provided by the commandline application or the selected framework.

For more details, see Bootstrapping Procedure, below.

Component Status
----------------

[](#component-status)

Under development.

Motivation
----------

[](#motivation)

Reduce maintenance by providing a common central library for bootstrapping, and allow for better sharing of general-purpose commands across frameworks. For example, the Drush sql-\* commands, which operate by calling SQL commandline tools, could be usable in other contexts if a general-purpose bootstrapping class provides the services it needs. This component aims to fill that need.

Bootstrapping Procedure
-----------------------

[](#bootstrapping-procedure)

In general, bootstrapping is not done for the command being run, but there are some exceptions.

The bootstrap object will automatically bootstrap to the framework code (known as DRUSH\_BOOTSTRAP\_ROOT in Drush) if necessary to identify the framework. This will allow frameworks to provide their own bootstrap object, if necessary.

If the selected command is not bootstrap-aware (signaled by implementing BootstrapAwareInterface), then its bootstrap level will depend on where the command was provided:

- Global commands are not bootstrapped at all. They have no access to the selected site unless they are bootstrap-aware.
- Site-specific commands are bootstrapped to the site code level.
- Module-provided commands are fully bootstrapped.

Services
--------

[](#services)

Bootstrap-aware classes can ask the bootstrap object for a service. Services are requested by a well-known identifier (string); the result will be either NOT FOUND, or a well-known interface, as determined by the service identifier. For example, the aforementioned SQL services might have a service identifier of 'sql', and might return an object that implements SQLInterface.

Each class of service will be provided by its own project.

Usage
-----

[](#usage)

```
$manager = new BootstrapManager();
$manager->add(new FrameworkBoot1());
$manager->add(new FrameworkBoot2());

$bootstrapObject = $manager->selectBootstrap('/path/to/framework/root');
$bootstrapObject->boot(['database']); // TODO: improve service feature specification

```

Dependency Injection
--------------------

[](#dependency-injection)

If your Dependency Injection container supports inflection, that feature may be used to ensure that any bootstrap-aware object created via the container will have its setBootstrap method called once a bootstrap object has been selected.

The example below shows configuration for league/container:

```
$container->share('bootstrapCurrator', 'Consolidation\Bootstrap\BootstrapCurrator');
$container->share('bootstrapManager', 'Consolidation\Bootstrap\BootstrapManager')
    ->withMethodCall('setBootstrapCurrator', ['bootstrapCurrator']);
$container->inflector('Consolidation\Bootstrap\BootstrapAwareInterface')
    ->invokeMethod('setBootstrapCurrator', ['bootstrapCurrator']);

```

If you are not using a container that supports inflection, or if you do not wish to instantiate all of your bootstrap-aware object instances via the container, then you may register your factory with the bootstrap manager, and it will ensure that the bootstrap object is injected as needed. Note that in order for this feature to work, the factory must provide a listener API, and notify the bootstrap manager when objects that might need to be set up are encountered.

```
$factory = new AnnotationCommandFactory();
$manager = new BootstrapManager();
$manager->registerFactory($factory);

```

Comparison to Existing Solutions
--------------------------------

[](#comparison-to-existing-solutions)

Drush has an existing `Boot` interface that is very similar to what is needed here. However, this class is tightly coupled with Drush; therefore, the implementation here will be slightly different.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b34cc6bd882277b6c6dda19bf6631ae5c3a909fd667c826a15121642cdc051b2?d=identicon)[greg.1.anderson](/maintainers/greg.1.anderson)

---

Top Contributors

[![greg-1-anderson](https://avatars.githubusercontent.com/u/612191?v=4)](https://github.com/greg-1-anderson "greg-1-anderson (14 commits)")

### Embed Badge

![Health badge](/badges/consolidation-bootstrap/health.svg)

```
[![Health](https://phpackages.com/badges/consolidation-bootstrap/health.svg)](https://phpackages.com/packages/consolidation-bootstrap)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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