Download the PHP package gacela-project/container without Composer

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

Gacela Container

GitHub Build Status Scrutinizer Code Quality Scrutinizer Code Coverage Psalm Type-coverage Status MIT Software License

A minimalistic, PSR-11 compliant dependency injection container with automatic constructor injection and zero configuration.

Features

Installation

Quick Start

Basic Usage

With Bindings

Map interfaces to concrete implementations:

Contextual Bindings

Different implementations based on which class needs them:

PHP 8 Attributes

Use attributes for declarative dependency configuration:

[Inject] - Specify Implementation

Override type hints to inject specific implementations:

[Singleton] - Single Instance

Mark a class to be instantiated only once:

[Factory] - New Instances

Always create fresh instances:

Performance Note: Attribute checks are cached internally, so repeated instantiations of the same class avoid expensive reflection operations, providing 15-20% performance improvement.

How It Works

The container automatically resolves dependencies based on type hints:

Example

Advanced Features

Factory Services

Create new instances on every call:

Extending Services

Wrap or modify services (even before they're created):

Protecting Closures

Prevent closures from being executed:

Resolving Callables

Automatically inject dependencies into any callable:

Service Introspection

Debug and inspect container state:

Performance Optimization

Pre-resolve dependencies for faster runtime:

Service Aliasing

Create multiple names for the same service:

API Reference

Container Methods

Method Description
get(string $id): mixed Retrieve or create a service
has(string $id): bool Check if service exists
set(string $id, mixed $instance): void Register a service
remove(string $id): void Remove a service
resolve(callable $callable): mixed Execute callable with dependency injection
factory(Closure $instance): Closure Mark service as factory (new instance each time)
extend(string $id, Closure $instance): Closure Wrap/modify a service
protect(Closure $instance): Closure Prevent closure execution
getRegisteredServices(): array Get all service IDs
isFactory(string $id): bool Check if service is a factory
isFrozen(string $id): bool Check if service is frozen
getBindings(): array Get all bindings
warmUp(array $classNames): void Pre-resolve dependencies
alias(string $alias, string $id): void Create an alias for a service (with caching)
getStats(): array Get container statistics for debugging and performance monitoring
when(string\|array $concrete): ContextualBindingBuilder Define contextual bindings for specific classes

Static Methods

Best Practices

1. Use Constructor Injection

2. Always Use Type Hints

3. Provide Default Values for Scalars

4. Use Bindings for Interfaces

5. Warm Up in Production

Error Handling

The container provides clear, actionable error messages with helpful suggestions:

Missing Type Hint

Circular Dependency

Unresolvable Scalar

Service Not Found (with suggestions)

Requirements

Testing

Real-World Example

See how it's used in the Gacela Framework

License

MIT License. See LICENSE file for details.


All versions of container with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
psr/container Version >=1.1
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 gacela-project/container contains the following files

Loading the files please wait ...