Download the PHP package metrophp/metrodi without Composer

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

metrodi

Small, smart dependency injector

tl;dr

Setup

Metro DI can be used by creating an object or as a singleton with globally namespaced functions.

With global functions it looks like this:

Things

In Metro DI you name your dependencies with the DI def function. An undefined thing will return a prototype object that logs all method calls used against it via the magic __call.

Constructor Injection

When an object is created with _make, the injector will inspect constructor arguments and find any defined things with the same name and pass them. Why not use class types? Well, imagine trying to switch an actual object implementation. You would have to change every file that has the old class type hint, or you would have to create a library full of interfaces in order to get ready for any potential switch in the future.

Some other languages don't have the benefit of being typeless. Using the name of the variable instead of the type hint (while still falling back to the type hint) allows for the most rapid prototyping and the most flexible changing of dependency implementations down the line.

Passing Parameters

You can pass parameters both when defining an object and when making an object.

Singletons

Singletons and new objects can both be access with _make() but it depends on how you use _make() with _didef().

If your object is not inherently a service and needs new constructor params everytime you make it, you can pass constructor params for every _make() call. Each unique combinations of parameters will be hashed and the resulting object will be cached and return on subsequent calls to _make()

You can combine both methods by supplying parameters to the _didef() which will be combined and used as defaults to subsequent _make() calls

The _makeNew() function will always return a new instance of a class definition regardless of parameters passed. It simply bypasses any instance cache and proceeds to make a new object the same way it does the very first time _make() is called.

Closures

Closures or any callbacks can be passed as the definition of any things as of 3.1.0.

The result of the anonymous function will be return from _make instead of the function object. This behavior defaults to behaving like a singleton where repeated calls to _make('connection') will return the same object.

To get a new reference and have the anonymous function invoked again, use _makeNew()

Service Providers

When you are making a thing from a class that defines public class variables and one of those variable names ends in 'Service', the dependency injector will automatically inject a lazy loading object for that service onto the object's variable.


All versions of metrodi with dependencies

PHP Build Version
Package Version
No informations.
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 metrophp/metrodi contains the following files

Loading the files please wait ....