Download the PHP package free-elephants/di without Composer

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

Simple PHP Constructor-based Dependency Injection

Build Status codecov Installs Releases

Configure less. Do more.

Framework-agnostic Dependency Injection tool and PSR-11 implementation provider.

Requirements

PHP 7.4|8+

Installation

Usage

Your entry php script (index.php or some background-job runner)

Your components.php file with dependencies description should look like this:

The main idea: all your components should expect all dependencies as constructor arguments. All other work entrust to Injector. You do not have to want to instantiate any classes directly in your code. Your must inject some factories instead.

Override Components by Environments

EnvAwareConfigLoader load config/components.php and merge it with config/components.test.php if it exists.

Options:

allowNullableConstructorArgs

Default value is false.

allowInstantiateNotRegisteredTypes

Default value is false. When you set it true, you can register only specific interfaces instances. All final typed dependency will be lazy-instantiated by chain!

useIdAsTypeName

Default value is true.

enableLoggerAwareInjection

Default value is false.

Allow to set LoggerInterface into LoggerAwareInterface instances after constructing, or use loggers map if type present.

Conception

[In Russian] Простейшее внедрение зависимостей через конструктор для PHP

В ООП можно выделить две большие группы классов по их ответственности: сущности и сервисы.

Сущности содержат данные и методы для работы с ними. Они чаще всего обладают состоянием и требуются во множестве экзепляров, создаваемых во время исполнения программы. Например:

Сервисы отвечают за всё остальное:

Сервис часто требуются в единственном экземпляре, и, редко меняет собственное состояние во время исполнения. Сервисы могут быть описаны до этапа исполнения, например в статическом файле, и быть получены в коде по требованию, или созданы единожды при запуске приложения.

Сущности не должны зависеть от сервисов. В то время, как сервисы наоборот — часто оперируют экземплярами сущностей. При этом сервисы могут использовать другие сервисы.

Наиболее явный и надёжный способ внедрения зависимостей, это инъекция в конструктор:

Type Hinting и рефлексия в php позволяют собрать готовый к использованию сервис на основе сигнатуры его конструктора, без лишних конфигурационных файлов и магии. Такой подход использован в free-elephants/di. Этот способ хорошо поддерживает рефакторинг, т.к. используется только нативный php-код, не требует статического описания зависимостей в yml, xml или аннотациях.


All versions of di with dependencies

PHP Build Version
Package Version
Requires psr/log Version ^1|^2|^3
psr/container Version ^1|^2
php Version ^7.4|^8.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 free-elephants/di contains the following files

Loading the files please wait ....