Download the PHP package xp-forge/inject without Composer

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

Inject

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.4+ Supports PHP 8.0+ Latest Stable Version

The inject package contains the XP framework's dependency injection API. Its entry point class is the "Injector".

Binding

Values can be bound to the injector by using its bind() method. It accepts the type to bind to, an optional name and these different scenarios:

Instance creation

Keep in mind: "injector.get() is the new 'new'". To create objects and perform injection, use the Injector's get() method instead of using the new keyword or factories.

Manual calls are usually not necessary though, instead you'll use injection:

Injection

Injection is performed by looking at a type's constructor. Bound values will be passed according to the given type hint.

You can supply the type by using parameter attributes in case where the PHP type system is not concise enough. If the bound value's name differs from the parameter name, you can supply a name argument.

When a required parameter is encountered and there is no bound value for this parameter, an inject.ProvisionException is raised.

Method and field injection are not supported.

Configuration

As seen above, bindings can be used instead of manually performing the wiring. You might want to configure some of your app's settings externally instead of harcoding them. Use the inject.ConfiguredBindings class for this:

The syntax for these INI files is simple:

Providers

Providers allow implementing lazy-loading semantics. Every type bound to the injector can also be retrieved by a provider. Invoking its get() method will instantiate it.

Named lookups

If we need control over the lookup, we can bind instances of Named:


All versions of inject with dependencies

PHP Build Version
Package Version
Requires xp-framework/core Version ^12.0 | ^11.0 | ^10.0
xp-framework/reflection Version ^3.0 | ^2.0
php Version >=7.4.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 xp-forge/inject contains the following files

Loading the files please wait ....