Download the PHP package jbuncle/simple-dic without Composer

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

PHP Simple DIC

A simple dependency injection container with focus on automatic wiring (auto-wiring) dependencies.

Introduction

Simple DIC is implemented with auto-wiring at the forefront.

This basically means that if a class can be created by automatically by recursively resolving dependencies then you will get a class back, even if you haven't manually put anything into the container!

For this to happen fully 100% automatically, all class constructor argumentss will need to have explicit type hints for instantiable types (i.e. they need to be non-abstract, non-interface, non-native).

If the types required are using interfaces and/or abstract classes then you can define a type mapping with the addTypeMapping method, to tell the container what concrete classes to resolve the types to.

If the types required have dependencies on native types (e.g. the constructor requires a string), then you can define factory methods to create the instance manually. You're factory method can define arguments which will also be autowired.

I have tried to optimise this implementation as much as possible.

Example

In the example below we are able to get an instance of the Foo class, simply be asking the container for one, no setup of the container is required other than instantiating it.

This will automatically instantiate instances of Foo, Bar and Baz, and store those instances in the container automatically. Therefore subsequently calling $container->getInstance(Bar::class) will give you the same class instance used to create Foo.

Adding Factory Functions

Factory functions allow you define a callback to use to manually create instances (lazily) when needed.

Useful for instances that cannot be created using full automatic autowiring.

Type Mapping

Type mapping allows you to tell the container what type to use when a specific type is requested.

This is useful for when you want to define what concrete or extending class to use when a supertype or interface is required.

PSR Compatibility

A simple DIC can be easily converted into a PHP FIG PSR-11 (psr/container v2) compatible implementation using the PsrAdapter wrapper class:


All versions of simple-dic with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
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 jbuncle/simple-dic contains the following files

Loading the files please wait ....