Skip to content

Conversation

@clue
Copy link
Owner

@clue clue commented Dec 17, 2021

This changeset adds support for dependency injection for factory functions in the Container configuration. This allows us to fine-tune the autowiring behavior and explicitly configure individual parameters while relying on autowiring defaults for other parameters. This does not otherwise break existing APIs, so this is a pure feature addition.

<?php

require __DIR__ . '/../vendor/autoload.php';

$container = new FrameworkX\Container([
    Acme\Todo\UserController::class => function (React\Http\Browser $browser) {
        // example UserController class requires two arguments:
        // - first argument will be autowired based on class reference
        // - second argument expects some manual value
        return new Acme\Todo\UserController($browser, 42);
    }
]);

// …

Builds on top of #96

@clue clue added the new feature New feature or request label Dec 17, 2021
@clue clue requested a review from SimonFrings December 17, 2021 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants