Download the PHP package hjerichen/class-instantiator without Composer

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

Continuous Integration Coverage Status

Class Instantiator

The class instantiator tries to create an object of the passed class recursively.

Some arguments for a constructor cannot be created automatically. For example primitive types like integer or interfaces.
Or you want to inject a specific object, that should not be created automatically, like a PDO object.
For those scenarios, there are multiple solutions.

Pass predefined arguments:

Extend the class instantiator:

Use an attribute to define a class instantiator extension:

Instantiate classes with an extension has a higher priority then using an attribute.
This allows overwriting the attribute and instantiate classes depending on your current needs.

You can also use the instantiator attribute to let the class build from a method in a specific instantiator:

The attribute can also be used on a constructor parameter:

The attribute on the parameter has a higher priority as the one on the class itself.

It is also possible to specify a method of the instantiator in the attribute.

Storing Objects

It is possible to sore objects permanently with an attribute.
Those objects will then be returned when a matching class is requested instead of creating a new one every time.

Storing objects with attribute does not work when the instantiation is done in the extension.
This is because of the higher priority for extensions.
But you can store objects as well when using the method "injectObject" inside the creation method of the extension.

Inject Objects

It is possible to inject objects into the class instantiator.
Those objects will be returned when a matching class is requested.

PSR-11 Container

There is also a PSR-11 Container Implementation. You can use this container in frameworks and libraries who support those.
Example for GraphQLite:

License and authors

This project is free and under the MIT Licence. Responsible for this project is Heiko Jerichen ([email protected]).


All versions of class-instantiator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
hjerichen/collections Version ^1.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 hjerichen/class-instantiator contains the following files

Loading the files please wait ....