Download the PHP package sotvokun/container without Composer

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

Container

English | 简体中文

An Illuminate container with opt-in attribute-driven AOP and lazy constructor injection. It retains Illuminate's dependency-injection API while allowing public service methods to be intercepted through PHP attributes.

Requirements

Installation

Usage

Sotvokun\Container\Container extends Illuminate\Container\Container. It is an Illuminate container with two opt-in capabilities: attribute-driven AOP and #[Lazy] constructor injection. When neither is enabled, normal Illuminate resolution semantics remain in effect.

Illuminate Container foundation

Use this container as you would Illuminate Container. It supports automatic constructor resolution, bindings and aliases, transient, singleton, and scoped lifecycles, contextual bindings, tags, extenders, resolving callbacks, makeWith(), and PSR-11 access.

This inheritance is deliberate: application code can keep using Illuminate's familiar dependency-injection API while selectively enabling the additional behavior below.

Attribute-driven AOP

AOP keeps cross-cutting work—such as tracing, auditing, authorization, retries, or transactions—out of business methods. Mark a method with an attribute; the attribute supplies interceptors that run around the original method.

When AOP is enabled, the container scans the configured source directories for supported method attributes. Ray AOP generates a subclass for each matching target, and the container resolves both the target and its interceptors. Calling MethodInvocation::proceed() advances through the interceptor chain and eventually invokes the original method.

Use AOP

First, define an attribute and interceptor:

Apply it to a service method, configure AOP before resolving the service, then resolve it normally:

AOP rules and limits

The scan directories and generated-class directory must be absolute paths. The generated directory must already exist, must be outside every scan directory, and should not be committed. Generate or warm the proxy cache in one process before starting concurrent Windows workers.

A target must be an instantiable, non-final class. An intercepted method must be declared directly on it and be public, non-static, non-final, and neither its constructor nor destructor. Private and protected attributed methods are ignored; inherited methods must be overridden and attributed on the concrete class.

Some PHP signatures and lifecycle patterns are not supported: named values collected by variadic parameters, never, parent parameter or return types, new default parameter expressions, reference parameters or returns, members colliding with Ray AOP internals such as _setBindings(), and calling an attributed method from the target constructor. See the unsupported capabilities report for details and workarounds.

Lazy constructor injection

Lazy injection postpones construction of an expensive or rarely used dependency until it is actually needed. This can avoid work and side effects on requests or jobs that never use that dependency.

Explicit factories with Illuminate Container

Without this package's #[Lazy] attribute, use an explicit factory. The factory makes the deferred dependency visible in the consumer's API and gives you complete control over when resolution happens:

ReportGenerator is constructed only when export() calls the factory. This is the usual Illuminate-compatible option when explicit lifetime control matters.

Attribute-based lazy injection

enableLazyInjection() registers the default resolver from the Lazy namespace through Illuminate's whenHasAttribute(). The attribute describes the dependency; the resolver validates it and creates the native proxy. Without registration, the attribute reports that lazy injection must be enabled. Custom resolver implementations are not currently a supported extension contract.

Enable lazy injection and annotate a supported object constructor parameter:

#[Lazy] creates a PHP 8.4 native lazy proxy with ReflectionClass::newLazyProxy(); it does not generate a lazy class file. #[Lazy(SpecialReportGenerator::class)] selects an explicit resolution key. The actual object is resolved through the normal container flow when PHP initializes the proxy.

Lazy injection is intentionally narrower than normal container resolution. It accepts only a single, non-builtin, non-variadic named object type whose concrete class can be determined without running user code. Union, intersection, builtin, untyped, self, parent, and variadic parameters are rejected. User closures or factories with no statically known concrete class are rejected, as are unsupported internal classes, abstract proxy classes, and enums. Compatible cached instances are injected directly.

A proxy and its actual object have different identities. An uninitialized scoped proxy resolves in the scope active at initialization; an initialized proxy retains its actual object after the container scope cache is cleared. Configure AOP, bindings, and aliases before creating a lazy consumer, then keep them stable until initialization. Unwoven stateless methods may not initialize a native lazy object; woven AOP methods do initialize it.

Operational costs and lifecycle discipline

AOP and lazy injection reduce repeated plumbing, but they also move work away from the source line that appears to perform it. AOP changes the runtime class and call stack, while lazy injection can move construction, callbacks, and failures to the first use of a dependency.

Use these features deliberately:

Development

composer test is the release gate and excludes the upstream PHPUnit group. The upstream tests keep their original successful contracts, so they intentionally return a non-zero status until Ray AOP fixes the recorded limitations. They remain available through composer test:upstream; composer test:all runs both scopes. The test report records the expected failures and the verified behavior matrix.

License

This package is open-sourced software licensed under the MIT License.


All versions of container with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
illuminate/container Version ^13.31
ray/aop Version ^2.20
composer/class-map-generator Version ^1.7
symfony/filesystem Version ^7.4
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 sotvokun/container contains the following files

Loading the files please wait ...