Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,22 @@ SECRET_KEY="abc123"
You can then load `.env` in your application with:

```php
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv = \Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
```

To suppress the exception that is thrown when there is no `.env` file, you can:

```php
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv = \Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();
```

Optionally you can pass in a filename as the second parameter, if you would
like to use something other than `.env`:

```php
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__, 'myconfig');
$dotenv = \Dotenv\Dotenv::createImmutable(__DIR__, 'myconfig');
$dotenv->load();
```

Expand Down Expand Up @@ -166,7 +166,7 @@ variables. If you want Dotenv to overwrite existing environment variables,
use `createMutable` instead of `createImmutable`:

```php
$dotenv = Dotenv\Dotenv::createMutable(__DIR__);
$dotenv = \Dotenv\Dotenv::createMutable(__DIR__);
$dotenv->load();
```

Expand All @@ -176,13 +176,13 @@ values by default, which is relevant if one is calling the "create" method
using the `RepositoryBuilder` to construct a more custom repository:

```php
$repository = Dotenv\Repository\RepositoryBuilder::createWithNoAdapters()
->addAdapter(Dotenv\Repository\Adapter\EnvConstAdapter::class)
->addWriter(Dotenv\Repository\Adapter\PutenvAdapter::class)
$repository = \Dotenv\Repository\RepositoryBuilder::createWithNoAdapters()
->addAdapter(\Dotenv\Repository\Adapter\EnvConstAdapter::class)
->addWriter(\Dotenv\Repository\Adapter\PutenvAdapter::class)
->immutable()
->make();

$dotenv = Dotenv\Dotenv::create($repository, __DIR__);
$dotenv = \Dotenv\Dotenv::create($repository, __DIR__);
$dotenv->load();
```

Expand All @@ -194,11 +194,11 @@ By means of another example, one can also specify a set of variables to be
allow listed. That is, only the variables in the allow list will be loaded:

```php
$repository = Dotenv\Repository\RepositoryBuilder::createWithDefaultAdapters()
$repository = \Dotenv\Repository\RepositoryBuilder::createWithDefaultAdapters()
->allowList(['FOO', 'BAR'])
->make();

$dotenv = Dotenv\Dotenv::create($repository, __DIR__);
$dotenv = \Dotenv\Dotenv::create($repository, __DIR__);
$dotenv->load();
```

Expand Down Expand Up @@ -330,13 +330,13 @@ Sometimes you just wanna parse the file and resolve the nested environment varia

```php
// ['FOO' => 'Bar', 'BAZ' => 'Hello Bar']
Dotenv\Dotenv::parse("FOO=Bar\nBAZ=\"Hello \${FOO}\"");
\Dotenv\Dotenv::parse("FOO=Bar\nBAZ=\"Hello \${FOO}\"");
```

This is exactly the same as:

```php
Dotenv\Dotenv::createArrayBacked(__DIR__)->load();
\Dotenv\Dotenv::createArrayBacked(__DIR__)->load();
```

only, instead of providing the directory to find the file, you have directly provided the file contents.
Expand Down