Download the PHP package idealogica/indi without Composer

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

InDI - [In]Dependency Injector


InDI

1. What is InDI?
2. Installation
3. Container values
4. Lazy initialization of container values
4.1. Defining shared values
4.2. Defining factory values
4.3. Accessing shared and factory values
5. Dependency injection
6. Value providers
7. Delegates
8. Integration
9. License

1. What is InDI?

InDI is the simplest [in]dependency injection container for PHP7, compatible with PSR-11. It offers intuitive way to manage PHP application dependencies mostly using native language constructs. The main idea is to provide painless way for programmers of any level of experience to use dependency injection in their projects. InDI is fast, easy to use, powerful and standards compliant. It doesn't provide sort of magic with automatic constructor arguments resolution, but I'm sure that it's a main advantage of InDI and such containers. Your code will always be readable and clear.

What is dependency injection?

It's a pattern that allows you to manage relations between your services and settings transparently. Using it you can build your application from a bunch of reusable decoupled components, distribute your initial settings over your application, write clear code that can be easily refactored, tested and maintained. There is a good explanatory article from Fabien Potencier.

InDI - more simple than Pimple

InDI is inspired by Pimple - another great dependency injection container for PHP. Their main principles are the same, so it won't take much of your time to start using InDI if you are an experienced Pimple user.

2. Installation

InDI requires PHP7 and psr/container package.

3. Container values

InDI is a simple key-value storage and you can add any kind of data to it. Any PHP variable can be stored inside InDI:

Values can be accessed in the similar way:

You can iterate over InDI values:

You can check that value exists:

Values that you set previously can be removed:

4. Lazy initialization of container values

Let's assume that you have database connection service. Of course, you can add it to container directly:

In this case database connection initializes instantly when you call new operator. If you want on-demand connection to your database you should use value lazy definition. Value lazy definition is a PHP callable that simply returns initialized value:

4.1. Defining shared values

You can pass value lazy definition to addShared method of container to get value shared across your application:

4.2. Defining factory values

Use addFactory method along with value lazy definition to obtain a new value instance every time you access it:

Notice that additional arguments can be defined in factory value lazy definition and then passed to it at runtime.

4.3. Accessing shared and factory values

Your previously defined shared or factory values can be accessed in two different ways:

► Directly form container:

► Using raw value lazy definition closure. Obtain it just like an any other regular value:

Later you can get shared or factory data by calling obtained closure:

It can be helpful when:

5. Dependency injection

Let's define all initial settings for our database connection and view classes:

Of course, you can inject these values to service that was added directly:

In case of lazy initialization you can inject any value from container in your value lazy definition. When value lazy definition is closure $this can be used to access container:

Anyway, for all PHP callables InDI can detect instance of Interop\Container\ContainerInterface in arguments and pass itself on its place:

Make sure that container argument is typehinted.

6. Value providers

If you want to create redistributable component and use it in different projects you should define value provider. It's also just a PHP callable like a value lazy definition:

As you can see, you can add additional arguments to callable along with container instance. Let's register our new value provider using container register method:

Value providers are executed right after they are registered.

7. Delegates

InDI can interact with any PSR-11 compliant dependency injection container. You can pass foreign container instance as a constructor argument to share values form it in two modes:

► Master mode. Allows to have all values from foreign container available in InDI:

► Lookup mode. Allows to have all values from foreign container available as a dependency lookups:

More details about delegate lookup feature you can find in PSR-11 documentation.

8. Integration

It's possible to integrate InDI into your project in few different ways:

► Most common and simple - just create InDI container instance and then use it:

► Inherit you main application class from Idealogica\InDI\Container:

► In case when your main application class is already inherited you can use traits to introduce InDI functionality:

9. License

InDI is licensed under a MIT License.


All versions of indi with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
psr/container Version ~1.0.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 idealogica/indi contains the following files

Loading the files please wait ....