Download the PHP package anax/di without Composer

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

Anax DI

Join the chat at https://gitter.im/canax/di Latest Stable Version

Build Status CircleCI

Build Status Scrutinizer Code Quality Code Coverage

Maintainability Codacy Badge

Anax DI service container for dependency injection of framework services using creation and lazy loading of services.

The implementation of the container is compliant with PHP-FIG PSR-11: Container interface

Table of content

You can also read this documentation online.

Install

You can install the module from anax/di on Packagist using composer.

Development

To work as a developer you clone the repo and install the local environment through make. Then you can run the unit tests.

Basic usage

This is the basic usage of the container.

First you create the container.

Add services onto the container.

Check if the service is loaded.

Get and use the service.

Shared service

A shared service always return the same object. The object is instantiated once and then stored for the next wanting to use the service. There is only one instance af a shared service. The service is shared among all its users.

A service that is not shared will return a new instance each time it is get from the container.

Lazy loading

The services added to the container are not activated until accessed. They are lazy loaded to ensure they are only active when used.

You can see what services are loaded onto the container and you can see what services are activated.

Usage in Anax

In Anax all services are loaded during the bootstrap phase in the file htdocs/index.php. It looks like this.

The variable $di is the only global variable within the framework. The main dependency, as a global variable, is to the be accessable within the view template files and view helpers.

Anax initialization of services

All the framework services are loaded from files in the directory ANAX_INSTALL_PATH . "/config/di". Each file contains one service. A file can contain several services.

This is a example of a service configuration file for the service "request".

A service may contain a callback that initiates the service when it is loaded. The callback should return the initiated object.

The service can be defined through its class name when the service needs no extra initialisation.

One common way to initialize the service is to inject $di into the service. This is an example of that.

Anax configuration of services

During the initialization phase some services might want to read additional configuration information. They can do so by using anax/configuration, like this.

First, lets have a look at the service "configuration".

It is a service to read configuration files from those directories that the framework specifies. It can be used like this, when creating other services that depends on their own configuration files.

The configuration setting "active" states wether the service should be activated when its loaded, or if it should be lazy loaded.

In the callback, first the service "configuration" is retrieved from $di. Then it is used to read the configuration file named "session".

The actual configuration is returned from the configuration file "session" and can then be used to configure and setup the object, before returning it as a framework service.

A configuration file is in general stored by its service name in ANAX_INSTALL_PATH . "/config/servicename.php". It should return something, like this.

Dependency

Using psr11 through psr/container.

License

This software carries a MIT license. See LICENSE.txt for details.


All versions of di with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
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 anax/di contains the following files

Loading the files please wait ....