Download the PHP package stefna/di without Composer

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

Dependency Injection

Build Status Latest Version on Packagist

This package is a lightweight dependency injection container that is framework-agnostic.

Requirements

PHP 8.2 or higher.

Installation

Usage

You will always have to use the ContainerBuilder to create a Container since we don't do any automatic autowiring, so you will have to define everything you want to have access to

Configure container

To configure you container you add DefinitionSource's to the container builder.

Bulk configure definitions

We provide 2 definition sources that can be used to bulk define stuff.

First you have FilterDefinition that just allows you to provide any arbitrary filter that will be matched against the requested class. And if it matches it will be given the definition.

Example:

We also provide a NamespaceFilterDefinition that makes it easier to bulk define everything in a specific namespace.

The NamespaceFilterDefinition just extends FilterDefinition and makes it easier to use with namespaces.

Example:

If your going to use this to provide auto-wiring to lots of classes I would recommend extending FilterDefintion and implement PriorityAware on the definition and return Priority::Low so you easily can override the "default" definition

Use with other container implementations

Autowiring

We do provide a helper that can do some lightweight autowiring.

The autowire helper will only look for dependencies in the container it will not try to auto create objects that aren't part of the container.

Attributes

You can augment the auto-wiring with attributes.

The auto-wire helper defaults to only fetch objects from the container.

We support 2 attribute interfaces

ResolverAttribute

Can be useful when you want to resolve a scalar value from something like a config storage.

ConfigureAttribute

Can be useful when you want to reconfigure something that being injected for example setting a custom log channel for this class.

Factories

Everything in the definition is in practice a factory.

But we provide a factory helper that can help with deduplicate factory instances and lazy instantiate the factory.

Autowiring factories

There are 2 ways to auto wire a factory

Option 1 add it to the container like anything else

Option 2 use the factory auto wire helper

This is just a nice wrapper around option 1

Contribute

We are always happy to receive bug/security reports and bug/security fixes

License

The MIT License (MIT). Please see License File for more information.


All versions of di with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
psr/container Version ^2.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 stefna/di contains the following files

Loading the files please wait ....