Skip to content

[3.2] Support direct loading with a string - #321

Merged
GrahamCampbell merged 3 commits into
phpdotenv:masterfrom
GrahamCampbell:direct-load
Jan 24, 2019
Merged

GrahamCampbell merged 3 commits into
phpdotenv:masterfrom
GrahamCampbell:direct-load

Conversation

@GrahamCampbell

@GrahamCampbell GrahamCampbell commented Jan 24, 2019 •

Copy link
Copy Markdown
Collaborator

Example usage, where $content is a string containing the content of some .env file:

<?php

use Dotenv\Environment\Adapter\ArrayAdapter;
use Dotenv\Environment\DotenvFactory;
use Dotenv\Loader;

$loader = new Loader([], new DotenvFactory([new ArrayAdapter()]));

$variables = $loader->loadDirect($content));

Why do we need the array adapter? This allows nested variables to work correctly, but avoid mutating your actual environment.'

@GrahamCampbell
GrahamCampbell merged commit 736602f into phpdotenv:master Jan 24, 2019
@GrahamCampbell
GrahamCampbell deleted the direct-load branch January 24, 2019 20:33
@GrahamCampbell GrahamCampbell changed the title Support direct loading with a string [3.2] Support direct loading with a string Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant