Skip to content

Support objects as container variables for factory functions#180

Merged
clue merged 1 commit intoclue:mainfrom
clue-labs:container-objects
Jul 29, 2022
Merged

Support objects as container variables for factory functions#180
clue merged 1 commit intoclue:mainfrom
clue-labs:container-objects

Conversation

@clue
Copy link
Owner

@clue clue commented Jul 29, 2022

This changeset adds support for object variables in the container configuration for all factory functions:

<?php

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

$container = new FrameworkX\Container([
    Acme\Todo\UserController::class => function (stdClass $site) {
        // example UserController class uses $site from explicit container configuration
        return new Acme\Todo\UserController($site);
    },
    'site' => (object) ['name' => 'ACME']
]);

// …

The previous version only supported scalar values (string, int, float, bool), we now support all object and scalar values. This is the next step in adding better configuration support and support for environment variables and .env (dotenv) files as discussed in #101.

Builds on top of #179, #178, #163, #97, #95 and others

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