Providers

Providers are a concept of League\Container: they’re simple classes that tell the container about a group of services they can provide. They only register those services in the container once at least one of those services is actually requested from the Container. Its important to keep that in mind.

Note

For more information about how Providers work refer to the League\Container: documentation.

Tip

Providers are central to Baleen CLI because they’re the main way services are registered into a container.

Bootstrap

The bootstrap.php file is the one that handles the initialization of the Container and adds providers to it. The sequence is as follows:

  1. Container is initialized with a few default services.
  2. The ConfigProvider gets registered as the first provider. This provider must provide the configuration service (named after the Services::CONFIG constant, which we’ll refer to as the “Config service”).
  3. The Config service is immediately fetched from the container.
  4. All providers supplied by the Config service are then added to the Container. At least one of them must supply the Service::APPLICATION service.
  5. The Application service is fetched and the Application::run() method is executed.

Customizing Providers

Providers can be customized (added, overwritten, removed, etc.) several ways:

  1. Directly in the bin/boostrap.php file. Not recommended, unless the provider can’t be configured.
  2. By modifying the config/providers.php file. This is the recommended method if you’re building your own migrations library (see the guide).
  3. On the end-user’s configuration file, under the “providers” section (similar to #2). This just give end-users the possibility to further customize the behaviour of the migrations library if desired.