Download the PHP package king23/di without Composer

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

License Latest Stable Version Total Downloads Scrutinizer Code Quality Code Coverage SensioLabsInsight

King23/DI, a dependency injection lib for King23

Copyright (C) 2015 - 2018 by Peter Petermann All rights reserved.

LICENSE

King23/DI is licensed under a MIT style license, see LICENSE.md for further information

REQUIREMENTS

USAGE

READTHIS

This DI container implements Psr-11, and can be used in the way Psr-11 describes it, however there are two things you should be aware of:

Installation

install using composer:

Hint: King23/DI follows Semantic Versioning v2.0.0, so you can set your version in composer to something like "~1.0"

Usage

Basically the container offers 4 Methods:

Hint: King23\DI uses $classname, as the parameter name, however this is equivalent to Psr-11's $id

register($interface, $implementation) is used to register dependencies for injection, while $interface can be any string in theory, it is meant to hold the name of an interface. The callable is supposed to be a method which should return a new instance of the interface (there is really nothing build in to stop you from using arbitrary strings, but the automated injection in the constructors when using getInstanceOf is using the type hints of the parameters. If you use any other string you can't have it automatic injected - which kind of voids the point. That said, it still can be of use when integrating King23/DI with frameworks that require specific keys in the DI). The object returned here will only be instanced once, further calls will return the same instance.

registerFactory($interface, $implementation) works the same way register() does, except that each time an instance of $interface is requested a new instance will be created.

get($classname), will return an object of type $classname, which gets the dependencies injected that are defined by the interfaces used in the type hints of its constructor. If called with a class/interfacename that has been used as a key in register/registerFactory, it will actually return an instance of the registered service. (psr-11)

has($classname), will return a boolean checking if the class/id is actually available (psr-11)

Examples

LINKS

CONTACT


All versions of di with dependencies

PHP Build Version
Package Version
Requires php Version >=8
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 king23/di contains the following files

Loading the files please wait ....