Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Container Laravel Package

league/container

PSR-11–compliant dependency injection container from The PHP League. Register services, factories and shared instances, then resolve dependencies with autowiring support. Modern PHP (8.3+) with full docs, tests, and MIT license.

View on GitHub
Deep Wiki
Context7

layout: post title: Getting Started sections: What is container?: what-is-container Goals: goals Questions?: questions Installation: installation

Author Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

What is Container?

Container is a small but powerful dependency injection container that allows you to decouple components in your application in order to write clean and testable code.

The container can automatically resolve dependencies of objects resolved through it.

Container on Packagist

Goals

  • Create a powerful dependency injection container that maintains speed and ease of use

Questions?

Container was created by Phil Bennett. Find him on Twitter at [@philipobenito](https://twitter.com/philipobenito).

Installation

System Requirements

You need PHP >= 5.4.0 to use League\Container but the latest stable version of PHP is recommended.

Composer

Container is available on Packagist and can be installed using Composer:

composer require league/container

Most modern frameworks will include Composer out of the box, but ensure the following file is included:

<?php

// include the Composer autoloader
require 'vendor/autoload.php';

Going Solo

You can also use Container without using Composer by registering an autoloader function:

spl_autoload_register(function ($class) {
    $prefix = 'League\\Container\\';
    $base_dir = __DIR__ . '/src/';
    $len = strlen($prefix);
    if (strncmp($prefix, $class, $len) !== 0) {
        // no, move to the next registered autoloader
        return;
    }
    $relative_class = substr($class, $len);
    $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
    if (file_exists($file)) {
        require $file;
    }
});

Or, use any other PSR-4 compatible autoloader.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport