Skip to content

Conversation

@clue
Copy link
Owner

@clue clue commented Aug 2, 2022

This changeset adds support for loading environment variables from the DI container configuration:

<?php

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

$container = new FrameworkX\Container([
    React\MySQL\ConnectionInterface::class => function (string $DB_HOST = 'localhost', string $DB_USER = 'root', string $DB_PASS = '', string $DB_NAME = 'acme') {
        // connect to database defined in optional $DB_* environment variables
        $uri = 'mysql://' . $DB_USER . ':' . rawurlencode($DB_PASS) . '@' . $DB_HOST . '/' . $DB_NAME . '?idle=0.001';
        return (new React\MySQL\Factory())->createLazyConnection($uri);
    }
]);

$app = new FrameworkX\App($container);

// …

The previous version only supported explicit configuration of container variables, we now also support automatically loading all environment variables with all uppercase names. This is the next big step in adding better configuration support and support for environment variables and .env (dotenv) files as discussed in #101.

Builds on top of #183, #182, #181, #180, #179, #178, #163, #97, #95 and others

@clue clue added the new feature New feature or request label Aug 2, 2022
@clue clue requested a review from SimonFrings August 2, 2022 11:55
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