Download the PHP package maduser/argon-container without Composer

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

PHP Build codecov Psalm Level Latest Version License: MIT

Argon Service Container

Argon is a high-performance, PSR-11 compliant dependency injection container with optional compilation.

It compiles your service graph into native PHP, eliminating reflection and runtime resolution overhead in production. Explicit bindings are preferred, but autowiring remains available when desired — allowing you to choose between strict, predictable behavior and dynamic flexibility.

Key Characteristics

Strict vs Dynamic

Strict mode resolves only explicitly registered services and throws NotFoundException for unbound classes.

Dynamic mode (default) prefers explicit bindings but can autowire instantiable classes and invoke closures when no compiled binding exists.

Strictness can be enforced at runtime or baked into the compiled container.


Installation

Requires PHP 8.2+

Tests & QA


Usage

Binding and Resolving Services

Tip: Bind aliases or interfaces before registering the services that consume them. Resolution happens immediately, so the container can only error, not infer, when a dependency is missing.

By default, every binding is shared. Prefer transient lifecycles instead? Pass sharedByDefault: false to the constructor and opt specific services back into shared mode when needed:

Binding Arguments

When registering a service, you can provide constructor arguments using an associative array.
These arguments are matched by name to the constructor’s parameter list — no need for full signatures or complex configuration.

Set arguments during binding

These arguments are attached to the service binding and used every time it's resolved.

Pass arguments during resolution

For transient services, runtime arguments may vary on every call. For shared services, runtime arguments are accepted only before the shared instance has been created; after that, passing runtime arguments throws a ContainerException instead of silently ignoring them. Prefer binding arguments for stable singleton configuration.

Automatic Dependency Resolution

Argon will resolve Logger by class name, and skip env because it's optional. In strict mode, autowiring only works when you bind the dependency (as shown above); otherwise a NotFoundException is thrown.

What will NOT work in either mode:

In this case, you must bind the interface to a concrete class first and provide a default value for the primitive:

Parameter Registry

The parameter registry is a built-in key/value store used to centralize application configuration. It is fully compatible with the compiled container — values are embedded directly into the generated service code.

Use it to define reusable values, inject environment settings.

Set and retrieve values

Use parameters in bindings or at resolution

TIP: you can wrap the parameter registry with your own "ConfigRepository" and implement validation, scopes via dot notation, etc.

Factory Bindings

Use factory() to bind a service to a dedicated factory class.
The factory itself is resolved via the container and may define either an __invoke() method or a named method. Arguments bound to the product service, or passed to get() for the product service, are applied to the factory method only. If the factory object needs configuration, bind the factory class itself with its own arguments.

This resolves and calls ClockFactory::__invoke().

To use a specific method:

Contextual Bindings

Contextual bindings allow different consumers to receive different implementations of the same interface.

Service Providers

Service providers allow grouping service bindings and optional boot-time logic.

Interceptors

Think of interceptors as a tiny, service-aware middleware pipeline wrapped around the resolver.
Each interceptor:

Because they are scoped to specific services (or interfaces), you get the flexibility of middleware without forcing every resolution through a monolithic stack.

Compiled containers embed the same pre/post pipeline: when you call compile(), the current interceptors are snapshot and generated into the compiled get() method, so short-circuit logic and decorators behave exactly as they do at runtime.

Post-Resolution Interceptors

These are executed after a service is created, and can modify the object (e.g., inject metadata, call validation, register hooks).

Pre-Resolution Interceptors

These run before a service is instantiated. They can modify constructor parameters or short-circuit the entire resolution.

Extending Services

extend() decorates a resolved service instance during runtime. It calls get() internally, so the service does not need to have been resolved before you extend it: a bound service is resolved immediately, then the decorated object replaces the binding for later calls.

From this point on, all calls to get(LoggerInterface::class) will return the wrapped instance.

In dynamic mode, extend() can also decorate an unbound concrete class that the container can autowire. In strict mode, or for missing non-autowireable IDs, it fails the same way get() would. Extending a transient binding currently replaces it with the decorated object for future resolutions.

Tags

Conditional Service Access

optional() is intentionally binding-based: it resolves the service only when a binding exists, otherwise it returns a no-op proxy. This is useful for optional collaborators, plugins, or integrations where "not registered" should mean "do nothing", even in dynamic mode where get() could autowire an unbound concrete class.

Closure Bindings with Autowired Parameters

Closure bindings are convenient for CLI tools, prototyping, or runtime-only services. Their parameters are resolved through the container at runtime, so dependencies can still be autowired.

Closures are not part of the compiled service graph. If a closure binding exists before compilation, either:

Skipped closures are not embedded in the generated class. In dynamic compiled containers, class-based skipped bindings can still fall back to normal autowiring; non-class runtime services should be registered during boot.

Compiling the Container

The compiled container is a pure PHP class with zero runtime resolution logic for standard bindings. In strict mode the generated class omits the dynamic fallback entirely—missing registrations fail fast with NotFoundException. In magic mode it continues to fall back to the runtime resolver when needed.

When strictMode is omitted, the compiler mirrors the source container's current strict-mode setting. Pass strictMode: false explicitly to force a lenient compiled container from a strict runtime container.

ArgonContainer API

ArgonContainer Parameters Return Description
set() string $id, Closure\|string\|null $concrete BindingBuilderInterface Registers a service using the container's default lifecycle (override with ->transient() or ->shared()).
get() string $id object Resolves and returns the service.
has() string $id bool Checks if a service binding exists.
getBindings() array<string, ServiceDescriptor> Returns all registered service descriptors.
getContextualBindings() ContextualBindingsInterface Returns all contextual service descriptors.
getDescriptor() string $id ServiceDescriptorInterface Returns the service description associated with the id.
getParameters() ParameterStoreInterface Access the parameter registry for raw or shared values.
registerInterceptor() class-string<InterceptorInterface> $class ArgonContainer Registers a type interceptor.
register() class-string<ServiceProviderInterface>\|list<class-string<ServiceProviderInterface>> $providers ArgonContainer Registers service provider(s) and runs their register() hooks.
tag() string $id, list<string> $tags ArgonContainer Tags a service with one or more labels.
getTags() array<string, list<string>> Returns all tag definitions in the container.
getTagged() string $tag list<object> Resolves all services tagged with the given label.
boot() ArgonContainer Bootstraps all registered service providers.
extend() string $id callable $decorator ArgonContainer Resolves then decorates a service, replacing the binding for future resolutions.
for() string $target ContextualBindingBuilder Begins a contextual binding chain — call ->set() to define per-target bindings.
getPreInterceptors() list<class-string<InterceptorInterface>> Lists all registered pre-interceptors.
getPostInterceptors() list<class-string<InterceptorInterface>> Lists all registered post-interceptors.
invoke() callable $target, array $params = [] mixed Calls a method or closure with injected dependencies.
isResolvable() string $id bool Checks if a service can be resolved, even if not explicitly bound.
optional() string $id object Resolves an explicitly bound service or returns a NullServiceProxy if unbound.
isStrictMode() bool Indicates whether the container was instantiated in strict mode.
isSharedByDefault() bool Reveals whether new bindings default to shared or transient lifecycle.

BindingBuilder API

When you call set(), it returns a BindingBuilder, which lets you configure the binding fluently.

Method Parameters Return Description
transient() BindingBuilderInterface Marks the service as non-shared. A new instance will be created for each request.
shared() BindingBuilderInterface Marks the service as shared, overriding a transient default if configured.
skipCompilation() BindingBuilderInterface Excludes this binding from the compiled container. Useful for closures or dynamic logic.
tag() string\|list<string> $tags BindingBuilderInterface Assigns one or more tags to this service.
factory() string $factoryClass, ?string $method = null BindingBuilderInterface Uses a factory class (optionally a method) to construct the service.
defineInvocation() string $methodName, array $args = [] BindingBuilderInterface Pre-defines arguments for a later invoke() call. Avoids reflection at runtime.
getDescriptor() ServiceDescriptorInterface Returns the internal service descriptor for advanced inspection or modification.

Troubleshooting

When errors persist, inspect the DebugTrace::toJson() output embedded in exceptions—it captures the entire resolution path that led to the failure.


License

MIT License


All versions of argon-container with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
nette/php-generator Version ^4.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 maduser/argon-container contains the following files

Loading the files please wait ...