Download the PHP package robotusers/cakephp-di without Composer

On this page you can find all versions of the php package robotusers/cakephp-di. 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 cakephp-di

CakePHP DI

codecov

PSR-11 compatible CakePHP Dependency Injection Container abstraction plugin

Under development

The plugin is under development and not intended to use in production yet.

Versions

For CakePHP 3.x use CakePHP DI 0.1.x versions. CakePHP DI 0.2.x is intended for CakePHP 4.0 and 4.1

For CakePHP 4.2 try 0.3 branch

Container Abstraction

This plugin provides tools for using any PSR-11 compatible DIC with CakePHP framework. DIC support for CakePHP is a very frequently requested feature. Although CakePHP is build with Dependency Injection in mind, it does not provide any build-in DIC. There are many great DI Containers out there and this plugin allows you to choose the one you like the most and use it with your CakePHP app.

Configuration

CakePHP DI plugin provides a Robotusers\DI\Core\ContainerApplicationInterface that your Application class should implement. This interface defines a getContainer() method that should return your PSR-11 compatible container.

The plugin provides a base application class that you can extend.

Note that the base class requires you to implement createContainer() method. That is a factory method for your container as getContainer() needs to return the same instance on each call.

The BaseApplication class also provides some wiring for action dispatcher so the controllers and actions use your DI Container.

Controllers

Controllers should be registered as a service in your DIC. The plugin tries to retrieve a controller from your DIC with the controller's FQCN as an id. For example: $container->get('App\Controller\ArticlesController');

The plugin also provides the ability to inject services into controller actions.

The services must be passed as a parameters to the action method. The precedence take the passed parameters, so for example your view method should look like this:

The ArticlesServiceInterface instance will be injected into the method.

Console

In order to fetch a console command from a DIC you need to use a CommandFactory provided with this plugin.

In your bin/cake.php:

Table Locator

Extending Robotusers\DI\Http\BaseApplication provides you with a DIC aware implementation of TableLocator. During the bootstrapping process the global instance of table locator is injected into TableRegistry.

Table locator replacement shipped with this plugin allows you to inject your own table factory.

By default a ContainerFactory is used which retrieves a table from your DIC using table's class name as an $id. Note that options are not passed to the DIC as PSR-11 implementation does not support passing extrac arguments to the get() method.

You either need to configure your table options using TableLocator::setConfig() method or configure your container to pass correct options.

You can also use custom implementation of table factory by overriding Application::createTableLocator() method. Table factory must be a callable that accepts $options array.


All versions of cakephp-di with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
cakephp/cakephp Version ^4.0,<4.2
psr/container Version ^1.0
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 robotusers/cakephp-di contains the following files

Loading the files please wait ....