Download the PHP package kaiseki/container-builder without Composer

On this page you can find all versions of the php package kaiseki/container-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package container-builder

kaiseki/container-builder

Create a PSR-11 dependency injection container with laminas-servicemanager and laminas-di


Table of Contents

Summary

This package is a bare-bone implementation that allows you to set up a dependency injection (DI) container quickly and easily. Use this package to build high-quality WordPress themes and plugins with modern PHP development methods.

It's not limited to WordPress though. That's just what we use it for. You can technically utilize it wherever you want.

Why you should use it?

While it may be daunting or seem like overhead at a first glance to use a DI container, it has many advantages. Once you clear the first hurdle of learning the basics, you will never want to go back doing things the old way.

To counter your first concern: No, this is not a framework. This package is simply a ready-to-use implementation to get you going with writing clean and awesome quality-code quickly. What you make of it is up to you.

But let's get back to the advantages of using a DI container:

  1. Firstly, you'll learn how to become a better developer.
  2. You will create cleaner and more readable code.
  3. Become more productive by creating reusable packages.
  4. Maintaining large projects becomes much easier.
  5. Your code will be more testable.

Technical Details

Important: You will need composer and set up autoloading to use this package.

The container builder creates a PSR-11 container, configured to use laminas-servicemanager and laminas-di.

After you have set up the autoloading and use the container builder you are ready to use dependency injection in your code.

What does the DI container do for you:

Usage (in a WordPress theme)

We'll explain the usage of this package inside a WordPress theme.

Typically kaiseki/container-builder is used in combination with packages that provide ConfigProviders are simple callables without dependencies, that return a config array.

In our example we additionaly set up the kaiseki/wp-hook package, that we use in many projects ourselves. It helps us to quickly register packages that will automatically set themselves up by hooking into WordPress actions and filters. This step is purely optional.

Installation

Setup

Add this to the top of your theme's functions.php file:

First, we'll define the path to a file resources/config-providers.php that returns an array of ConfigProviders that we wish to load. More on that later.

Next we define the folder that will contain our configuration files with withConfigFolder(). All files inside this folder ending with .global.php will be loaded first and files ending with .local.php will be loaded last. This allows you to override settings in the global config with local settings (which you should obviously add to .gitignore).

In the last step, we build our container with build().

Install and initialize the wp-hook package (optional)

Now that our container is built we can initialize the kaiseki/wp-hook package. All packages that want to hook into WordPress actions and filters will do so at this point.

Install kaiseki/wp-hook first,

Then add this line of code after the container was built.

Config Providers

So what's actually a ConfigProvider?

In the most basic sense, they return a configuration array.

Often they will contain information about dependencies.

ConfigProviders are for example the place where you instruct your application which factory should create a Class that gets injected into another Class.

They also contain aliases so your application knows which implementation of an Interface to inject into a Class that depends on it.

You can read more on that by checking out the documentation for the laminas-servicemanager.

In our case we want to load our two packages' ConfigProviders so we'll add those to resources/config-providers.php:


All versions of container-builder with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
laminas/laminas-config-aggregator Version ^1.7
laminas/laminas-di Version ^3.3
laminas/laminas-servicemanager Version ^3.10
psr/container Version ^1.1
thecodingmachine/safe Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kaiseki/container-builder contains the following files

Loading the files please wait ....