create-berna-stencil 2.0.8 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eleventy.js +38 -19
- package/README.md +1 -1
- package/bin/create.js +1 -1
- package/docs/Components.md +12 -0
- package/docs/Creating pages.md +1 -2
- package/package.json +63 -61
- package/src/backend/_core/vendor/composer/autoload_static.php +10 -10
- package/src/backend/_core/vendor/composer/installed.json +6 -6
- package/src/backend/_core/vendor/composer/installed.php +2 -2
- package/src/backend/_core/vendor/graham-campbell/result-type/LICENSE +21 -21
- package/src/backend/_core/vendor/graham-campbell/result-type/composer.json +33 -33
- package/src/backend/_core/vendor/graham-campbell/result-type/src/Error.php +121 -121
- package/src/backend/_core/vendor/graham-campbell/result-type/src/Result.php +69 -69
- package/src/backend/_core/vendor/graham-campbell/result-type/src/Success.php +120 -120
- package/src/backend/_core/vendor/phpoption/phpoption/LICENSE +200 -200
- package/src/backend/_core/vendor/phpoption/phpoption/composer.json +50 -50
- package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/LazyOption.php +175 -175
- package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/None.php +136 -136
- package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/Option.php +434 -434
- package/src/backend/_core/vendor/phpoption/phpoption/src/PhpOption/Some.php +169 -169
- package/src/backend/_core/vendor/symfony/polyfill-ctype/Ctype.php +232 -232
- package/src/backend/_core/vendor/symfony/polyfill-ctype/LICENSE +19 -19
- package/src/backend/_core/vendor/symfony/polyfill-ctype/README.md +12 -12
- package/src/backend/_core/vendor/symfony/polyfill-ctype/bootstrap.php +50 -50
- package/src/backend/_core/vendor/symfony/polyfill-ctype/bootstrap80.php +46 -46
- package/src/backend/_core/vendor/symfony/polyfill-ctype/composer.json +38 -38
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/LICENSE +19 -19
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/Mbstring.php +1077 -1077
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/README.md +13 -13
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php +119 -119
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +1397 -1397
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php +5 -5
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php +1489 -1489
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/bootstrap.php +171 -171
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/bootstrap80.php +167 -167
- package/src/backend/_core/vendor/symfony/polyfill-mbstring/composer.json +39 -39
- package/src/backend/_core/vendor/symfony/polyfill-php80/LICENSE +19 -19
- package/src/backend/_core/vendor/symfony/polyfill-php80/Php80.php +115 -115
- package/src/backend/_core/vendor/symfony/polyfill-php80/PhpToken.php +106 -106
- package/src/backend/_core/vendor/symfony/polyfill-php80/README.md +25 -25
- package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php +31 -31
- package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php +16 -16
- package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php +20 -20
- package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php +16 -16
- package/src/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php +16 -16
- package/src/backend/_core/vendor/symfony/polyfill-php80/bootstrap.php +42 -42
- package/src/backend/_core/vendor/symfony/polyfill-php80/composer.json +37 -37
- package/src/backend/_core/vendor/vlucas/phpdotenv/LICENSE +30 -30
- package/src/backend/_core/vendor/vlucas/phpdotenv/composer.json +60 -60
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Dotenv.php +267 -267
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php +12 -12
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidEncodingException.php +12 -12
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php +12 -12
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php +12 -12
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Exception/ValidationException.php +12 -12
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Loader/Loader.php +48 -48
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Loader/LoaderInterface.php +20 -20
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Loader/Resolver.php +65 -65
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Entry.php +59 -59
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/EntryParser.php +299 -299
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Lexer.php +58 -58
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Lines.php +127 -127
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Parser.php +53 -53
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/ParserInterface.php +19 -19
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Value.php +88 -88
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/AdapterInterface.php +15 -15
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php +89 -89
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php +80 -80
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php +88 -88
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/GuardedWriter.php +85 -85
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ImmutableWriter.php +110 -110
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiReader.php +48 -48
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiWriter.php +64 -64
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php +91 -91
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php +17 -17
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReplacingWriter.php +104 -104
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php +88 -88
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php +27 -27
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/AdapterRepository.php +107 -107
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php +272 -272
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php +51 -51
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/File/Paths.php +44 -44
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/File/Reader.php +81 -81
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/FileStore.php +72 -72
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php +141 -141
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/StoreInterface.php +17 -17
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Store/StringStore.php +37 -37
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Util/Regex.php +112 -112
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Util/Str.php +108 -108
- package/src/backend/_core/vendor/vlucas/phpdotenv/src/Validator.php +207 -207
- package/src/frontend/components/layouts/base.njk +47 -34
- package/src/frontend/components/welcome.njk +32 -668
- package/src/frontend/data/site.json +43 -43
- package/src/frontend/scss/modules/_global.scss +0 -1
- package/src/backend/_core/vendor/graham-campbell/result-type/.gitattributes +0 -9
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/CODE_OF_CONDUCT.md +0 -132
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/CONTRIBUTING.md +0 -31
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/FUNDING.yml +0 -2
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/SECURITY.md +0 -14
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/workflows/stale.yml +0 -11
- package/src/backend/_core/vendor/graham-campbell/result-type/.github/workflows/tests.yml +0 -40
- package/src/backend/_core/vendor/graham-campbell/result-type/CHANGELOG.md +0 -53
- package/src/backend/_core/vendor/graham-campbell/result-type/README.md +0 -42
- package/src/backend/_core/vendor/graham-campbell/result-type/phpunit.xml.dist +0 -13
- package/src/backend/_core/vendor/graham-campbell/result-type/tests/ResultTest.php +0 -95
- package/src/backend/_core/vendor/phpoption/phpoption/.gitattributes +0 -13
- package/src/backend/_core/vendor/phpoption/phpoption/.github/CODE_OF_CONDUCT.md +0 -132
- package/src/backend/_core/vendor/phpoption/phpoption/.github/CONTRIBUTING.md +0 -30
- package/src/backend/_core/vendor/phpoption/phpoption/.github/FUNDING.yml +0 -2
- package/src/backend/_core/vendor/phpoption/phpoption/.github/SECURITY.md +0 -14
- package/src/backend/_core/vendor/phpoption/phpoption/.github/workflows/static.yml +0 -40
- package/src/backend/_core/vendor/phpoption/phpoption/.github/workflows/tests.yml +0 -40
- package/src/backend/_core/vendor/phpoption/phpoption/Makefile +0 -17
- package/src/backend/_core/vendor/phpoption/phpoption/README.md +0 -201
- package/src/backend/_core/vendor/phpoption/phpoption/phpstan-baseline.neon +0 -44
- package/src/backend/_core/vendor/phpoption/phpoption/phpstan.neon.dist +0 -7
- package/src/backend/_core/vendor/phpoption/phpoption/phpunit.xml.dist +0 -13
- package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/EnsureTest.php +0 -72
- package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/LazyOptionTest.php +0 -357
- package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/NoneTest.php +0 -153
- package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/OptionTest.php +0 -166
- package/src/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/SomeTest.php +0 -194
- package/src/backend/_core/vendor/phpoption/phpoption/tests/bootstrap.php +0 -8
- package/src/backend/_core/vendor/phpoption/phpoption/vendor-bin/phpstan/composer.json +0 -8
- package/src/backend/_core/vendor/vlucas/phpdotenv/.editorconfig +0 -15
- package/src/backend/_core/vendor/vlucas/phpdotenv/.gitattributes +0 -15
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/CODE_OF_CONDUCT.md +0 -132
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/CONTRIBUTING.md +0 -30
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/FUNDING.yml +0 -2
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/SECURITY.md +0 -14
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/workflows/static.yml +0 -40
- package/src/backend/_core/vendor/vlucas/phpdotenv/.github/workflows/tests.yml +0 -70
- package/src/backend/_core/vendor/vlucas/phpdotenv/Makefile +0 -17
- package/src/backend/_core/vendor/vlucas/phpdotenv/README.md +0 -370
- package/src/backend/_core/vendor/vlucas/phpdotenv/UPGRADING.md +0 -196
- package/src/backend/_core/vendor/vlucas/phpdotenv/phpstan-baseline.neon +0 -157
- package/src/backend/_core/vendor/vlucas/phpdotenv/phpstan.neon.dist +0 -7
- package/src/backend/_core/vendor/vlucas/phpdotenv/phpunit.xml.dist +0 -13
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/DotenvTest.php +0 -387
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Loader/LoaderTest.php +0 -86
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/EntryParserTest.php +0 -234
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LexerTest.php +0 -40
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LinesTest.php +0 -53
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/ParserTest.php +0 -98
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ArrayAdapterTest.php +0 -57
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/EnvConstAdapterTest.php +0 -75
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/PutenvAdapterTest.php +0 -52
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ServerConstAdapterTest.php +0 -75
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/RepositoryTest.php +0 -305
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Store/StoreTest.php +0 -141
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/ValidatorTest.php +0 -479
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/.env +0 -5
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/assertions.env +0 -18
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/booleans.env +0 -33
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/commented.env +0 -15
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/empty.env +0 -1
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/example.env +0 -1
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/exported.env +0 -7
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/immutable.env +0 -1
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/integers.env +0 -17
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/large.env +0 -2
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multibyte.env +0 -3
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multiline.env +0 -14
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multiple.env +0 -4
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/mutable.env +0 -1
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/nested.env +0 -15
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/quoted.env +0 -11
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/specialchars.env +0 -8
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/unicodevarnames.env +0 -2
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/utf8-with-bom-encoding.env +0 -3
- package/src/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/windows.env +0 -1
- package/src/backend/_core/vendor/vlucas/phpdotenv/vendor-bin/phpstan/composer.json +0 -15
- package/src/backend/config.php +0 -19
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
PHP dotenv
|
|
2
|
-
==========
|
|
3
|
-
|
|
4
|
-
Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
|
|
5
|
-
|
|
6
|
-

|
|
7
|
-
|
|
8
|
-
<p align="center">
|
|
9
|
-
<a href="LICENSE"><img src="https://img.shields.io/badge/license-BSD%203--Clause-brightgreen.svg?style=flat-square" alt="Software License"></img></a>
|
|
10
|
-
<a href="https://packagist.org/packages/vlucas/phpdotenv"><img src="https://img.shields.io/packagist/dt/vlucas/phpdotenv.svg?style=flat-square" alt="Total Downloads"></img></a>
|
|
11
|
-
<a href="https://github.com/vlucas/phpdotenv/releases"><img src="https://img.shields.io/github/release/vlucas/phpdotenv.svg?style=flat-square" alt="Latest Version"></img></a>
|
|
12
|
-
</p>
|
|
13
|
-
|
|
14
|
-
<div align="center">
|
|
15
|
-
|
|
16
|
-
**Special thanks to [our sponsors](https://github.com/sponsors/GrahamCampbell)**
|
|
17
|
-
|
|
18
|
-
<hr>
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## Why .env?
|
|
23
|
-
|
|
24
|
-
**You should never store sensitive credentials in your code**. Storing
|
|
25
|
-
[configuration in the environment](https://www.12factor.net/config) is one of
|
|
26
|
-
the tenets of a [twelve-factor app](https://www.12factor.net/). Anything that
|
|
27
|
-
is likely to change between deployment environments – such as database
|
|
28
|
-
credentials or credentials for 3rd party services – should be extracted from
|
|
29
|
-
the code into environment variables.
|
|
30
|
-
|
|
31
|
-
Basically, a `.env` file is an easy way to load custom configuration variables
|
|
32
|
-
that your application needs without having to modify .htaccess files or
|
|
33
|
-
Apache/nginx virtual hosts. This means you won't have to edit any files outside
|
|
34
|
-
the project, and all the environment variables are always set no matter how you
|
|
35
|
-
run your project - Apache, Nginx, CLI, and even PHP's built-in webserver. It's
|
|
36
|
-
WAY easier than all the other ways you know of to set environment variables,
|
|
37
|
-
and you're going to love it!
|
|
38
|
-
|
|
39
|
-
* NO editing virtual hosts in Apache or Nginx
|
|
40
|
-
* NO adding `php_value` flags to .htaccess files
|
|
41
|
-
* EASY portability and sharing of required ENV values
|
|
42
|
-
* COMPATIBLE with PHP's built-in web server and CLI runner
|
|
43
|
-
|
|
44
|
-
PHP dotenv is a PHP version of the original [Ruby
|
|
45
|
-
dotenv](https://github.com/bkeepers/dotenv).
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## Installation
|
|
49
|
-
|
|
50
|
-
Installation is super-easy via [Composer](https://getcomposer.org/):
|
|
51
|
-
|
|
52
|
-
```bash
|
|
53
|
-
$ composer require vlucas/phpdotenv
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
or add it by hand to your `composer.json` file.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
## Upgrading
|
|
60
|
-
|
|
61
|
-
We follow [semantic versioning](https://semver.org/), which means breaking
|
|
62
|
-
changes may occur between major releases. We have upgrading guides available
|
|
63
|
-
for V2 to V3, V3 to V4 and V4 to V5 available [here](UPGRADING.md).
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
## Usage
|
|
67
|
-
|
|
68
|
-
The `.env` file is generally kept out of version control since it can contain
|
|
69
|
-
sensitive API keys and passwords. A separate `.env.example` file is created
|
|
70
|
-
with all the required environment variables defined except for the sensitive
|
|
71
|
-
ones, which are either user-supplied for their own development environments or
|
|
72
|
-
are communicated elsewhere to project collaborators. The project collaborators
|
|
73
|
-
then independently copy the `.env.example` file to a local `.env` and ensure
|
|
74
|
-
all the settings are correct for their local environment, filling in the secret
|
|
75
|
-
keys or providing their own values when necessary. In this usage, the `.env`
|
|
76
|
-
file should be added to the project's `.gitignore` file so that it will never
|
|
77
|
-
be committed by collaborators. This usage ensures that no sensitive passwords
|
|
78
|
-
or API keys will ever be in the version control history so there is less risk
|
|
79
|
-
of a security breach, and production values will never have to be shared with
|
|
80
|
-
all project collaborators.
|
|
81
|
-
|
|
82
|
-
Add your application configuration to a `.env` file in the root of your
|
|
83
|
-
project. **Make sure the `.env` file is added to your `.gitignore` so it is not
|
|
84
|
-
checked-in the code**
|
|
85
|
-
|
|
86
|
-
```shell
|
|
87
|
-
S3_BUCKET="dotenv"
|
|
88
|
-
SECRET_KEY="souper_seekret_key"
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Now create a file named `.env.example` and check this into the project. This
|
|
92
|
-
should have the ENV variables you need to have set, but the values should
|
|
93
|
-
either be blank or filled with dummy data. The idea is to let people know what
|
|
94
|
-
variables are required, but not give them the sensitive production values.
|
|
95
|
-
|
|
96
|
-
```shell
|
|
97
|
-
S3_BUCKET="devbucket"
|
|
98
|
-
SECRET_KEY="abc123"
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
You can then load `.env` in your application with:
|
|
102
|
-
|
|
103
|
-
```php
|
|
104
|
-
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
|
105
|
-
$dotenv->load();
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
To suppress the exception that is thrown when there is no `.env` file, you can:
|
|
109
|
-
|
|
110
|
-
```php
|
|
111
|
-
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
|
112
|
-
$dotenv->safeLoad();
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Optionally you can pass in a filename as the second parameter, if you would
|
|
116
|
-
like to use something other than `.env`:
|
|
117
|
-
|
|
118
|
-
```php
|
|
119
|
-
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__, 'myconfig');
|
|
120
|
-
$dotenv->load();
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
All of the defined variables are now available in the `$_ENV` and `$_SERVER`
|
|
124
|
-
super-globals.
|
|
125
|
-
|
|
126
|
-
```php
|
|
127
|
-
$s3_bucket = $_ENV['S3_BUCKET'];
|
|
128
|
-
$s3_bucket = $_SERVER['S3_BUCKET'];
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
### Putenv and Getenv
|
|
133
|
-
|
|
134
|
-
Using `getenv()` and `putenv()` is strongly discouraged due to the fact that
|
|
135
|
-
these functions are not thread safe, however it is still possible to instruct
|
|
136
|
-
PHP dotenv to use these functions. Instead of calling
|
|
137
|
-
`Dotenv::createImmutable`, one can call `Dotenv::createUnsafeImmutable`, which
|
|
138
|
-
will add the `PutenvAdapter` behind the scenes. Your environment variables will
|
|
139
|
-
now be available using the `getenv` method, as well as the super-globals:
|
|
140
|
-
|
|
141
|
-
```php
|
|
142
|
-
$s3_bucket = getenv('S3_BUCKET');
|
|
143
|
-
$s3_bucket = $_ENV['S3_BUCKET'];
|
|
144
|
-
$s3_bucket = $_SERVER['S3_BUCKET'];
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
### Nesting Variables
|
|
149
|
-
|
|
150
|
-
It's possible to nest an environment variable within another, useful to cut
|
|
151
|
-
down on repetition.
|
|
152
|
-
|
|
153
|
-
This is done by wrapping an existing environment variable in `${…}` e.g.
|
|
154
|
-
|
|
155
|
-
```shell
|
|
156
|
-
BASE_DIR="/var/webroot/project-root"
|
|
157
|
-
CACHE_DIR="${BASE_DIR}/cache"
|
|
158
|
-
TMP_DIR="${BASE_DIR}/tmp"
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
### Immutability and Repository Customization
|
|
163
|
-
|
|
164
|
-
Immutability refers to if Dotenv is allowed to overwrite existing environment
|
|
165
|
-
variables. If you want Dotenv to overwrite existing environment variables,
|
|
166
|
-
use `createMutable` instead of `createImmutable`:
|
|
167
|
-
|
|
168
|
-
```php
|
|
169
|
-
$dotenv = Dotenv\Dotenv::createMutable(__DIR__);
|
|
170
|
-
$dotenv->load();
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
Behind the scenes, this is instructing the "repository" to allow immutability
|
|
174
|
-
or not. By default, the repository is configured to allow overwriting existing
|
|
175
|
-
values by default, which is relevant if one is calling the "create" method
|
|
176
|
-
using the `RepositoryBuilder` to construct a more custom repository:
|
|
177
|
-
|
|
178
|
-
```php
|
|
179
|
-
$repository = Dotenv\Repository\RepositoryBuilder::createWithNoAdapters()
|
|
180
|
-
->addAdapter(Dotenv\Repository\Adapter\EnvConstAdapter::class)
|
|
181
|
-
->addWriter(Dotenv\Repository\Adapter\PutenvAdapter::class)
|
|
182
|
-
->immutable()
|
|
183
|
-
->make();
|
|
184
|
-
|
|
185
|
-
$dotenv = Dotenv\Dotenv::create($repository, __DIR__);
|
|
186
|
-
$dotenv->load();
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
The above example will write loaded values to `$_ENV` and `putenv`, but when
|
|
190
|
-
interpolating environment variables, we'll only read from `$_ENV`. Moreover, it
|
|
191
|
-
will never replace any variables already set before loading the file.
|
|
192
|
-
|
|
193
|
-
By means of another example, one can also specify a set of variables to be
|
|
194
|
-
allow listed. That is, only the variables in the allow list will be loaded:
|
|
195
|
-
|
|
196
|
-
```php
|
|
197
|
-
$repository = Dotenv\Repository\RepositoryBuilder::createWithDefaultAdapters()
|
|
198
|
-
->allowList(['FOO', 'BAR'])
|
|
199
|
-
->make();
|
|
200
|
-
|
|
201
|
-
$dotenv = Dotenv\Dotenv::create($repository, __DIR__);
|
|
202
|
-
$dotenv->load();
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
### Requiring Variables to be Set
|
|
207
|
-
|
|
208
|
-
PHP dotenv has built in validation functionality, including for enforcing the
|
|
209
|
-
presence of an environment variable. This is particularly useful to let people
|
|
210
|
-
know any explicit required variables that your app will not work without.
|
|
211
|
-
|
|
212
|
-
You can use a single string:
|
|
213
|
-
|
|
214
|
-
```php
|
|
215
|
-
$dotenv->required('DATABASE_DSN');
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
Or an array of strings:
|
|
219
|
-
|
|
220
|
-
```php
|
|
221
|
-
$dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS']);
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
If any ENV vars are missing, Dotenv will throw a `RuntimeException` like this:
|
|
225
|
-
|
|
226
|
-
```
|
|
227
|
-
One or more environment variables failed assertions: DATABASE_DSN is missing
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
### Empty Variables
|
|
232
|
-
|
|
233
|
-
Beyond simply requiring a variable to be set, you might also need to ensure the
|
|
234
|
-
variable is not empty:
|
|
235
|
-
|
|
236
|
-
```php
|
|
237
|
-
$dotenv->required('DATABASE_DSN')->notEmpty();
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
If the environment variable is empty, you'd get an Exception:
|
|
241
|
-
|
|
242
|
-
```
|
|
243
|
-
One or more environment variables failed assertions: DATABASE_DSN is empty
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
### Integer Variables
|
|
248
|
-
|
|
249
|
-
You might also need to ensure that the variable is of an integer value. You may
|
|
250
|
-
do the following:
|
|
251
|
-
|
|
252
|
-
```php
|
|
253
|
-
$dotenv->required('FOO')->isInteger();
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
If the environment variable is not an integer, you'd get an Exception:
|
|
257
|
-
|
|
258
|
-
```
|
|
259
|
-
One or more environment variables failed assertions: FOO is not an integer.
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
One may only want to enforce validation rules when a variable is set. We
|
|
263
|
-
support this too:
|
|
264
|
-
|
|
265
|
-
```php
|
|
266
|
-
$dotenv->ifPresent('FOO')->isInteger();
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
### Boolean Variables
|
|
271
|
-
|
|
272
|
-
You may need to ensure a variable is in the form of a boolean, accepting
|
|
273
|
-
"true", "false", "On", "1", "Yes", "Off", "0" and "No". You may do the
|
|
274
|
-
following:
|
|
275
|
-
|
|
276
|
-
```php
|
|
277
|
-
$dotenv->required('FOO')->isBoolean();
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
If the environment variable is not a boolean, you'd get an Exception:
|
|
281
|
-
|
|
282
|
-
```
|
|
283
|
-
One or more environment variables failed assertions: FOO is not a boolean.
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
Similarly, one may write:
|
|
287
|
-
|
|
288
|
-
```php
|
|
289
|
-
$dotenv->ifPresent('FOO')->isBoolean();
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
### Allowed Values
|
|
294
|
-
|
|
295
|
-
It is also possible to define a set of values that your environment variable
|
|
296
|
-
should be. This is especially useful in situations where only a handful of
|
|
297
|
-
options or drivers are actually supported by your code:
|
|
298
|
-
|
|
299
|
-
```php
|
|
300
|
-
$dotenv->required('SESSION_STORE')->allowedValues(['Filesystem', 'Memcached']);
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
If the environment variable wasn't in this list of allowed values, you'd get a
|
|
304
|
-
similar Exception:
|
|
305
|
-
|
|
306
|
-
```
|
|
307
|
-
One or more environment variables failed assertions: SESSION_STORE is not an allowed value.
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
It is also possible to define a regex that your environment variable should be.
|
|
311
|
-
```php
|
|
312
|
-
$dotenv->required('FOO')->allowedRegexValues('([[:lower:]]{3})');
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
### Comments
|
|
317
|
-
|
|
318
|
-
You can comment your `.env` file using the `#` character. E.g.
|
|
319
|
-
|
|
320
|
-
```shell
|
|
321
|
-
# this is a comment
|
|
322
|
-
VAR="value" # comment
|
|
323
|
-
VAR=value # comment
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
### Parsing Without Loading
|
|
328
|
-
|
|
329
|
-
Sometimes you just wanna parse the file and resolve the nested environment variables, by giving us a string, and have an array returned back to you. While this is already possible, it is a little fiddly, so we have provided a direct way to do this:
|
|
330
|
-
|
|
331
|
-
```php
|
|
332
|
-
// ['FOO' => 'Bar', 'BAZ' => 'Hello Bar']
|
|
333
|
-
Dotenv\Dotenv::parse("FOO=Bar\nBAZ=\"Hello \${FOO}\"");
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
This is exactly the same as:
|
|
337
|
-
|
|
338
|
-
```php
|
|
339
|
-
Dotenv\Dotenv::createArrayBacked(__DIR__)->load();
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
only, instead of providing the directory to find the file, you have directly provided the file contents.
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
### Usage Notes
|
|
346
|
-
|
|
347
|
-
When a new developer clones your codebase, they will have an additional
|
|
348
|
-
one-time step to manually copy the `.env.example` file to `.env` and fill-in
|
|
349
|
-
their own values (or get any sensitive values from a project co-worker).
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
### Troubleshooting
|
|
353
|
-
|
|
354
|
-
In certain server setups (most commonly found in shared hosting), PHP might deactivate superglobals like `$_ENV` or `$_SERVER`. If these variables are not set, review the `variables_order` in the `php.ini` file. See [php.net/manual/en/ini.core.php#ini.variables-order](https://www.php.net/manual/en/ini.core.php#ini.variables-order).
|
|
355
|
-
|
|
356
|
-
## Security
|
|
357
|
-
|
|
358
|
-
If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. You may view our full security policy [here](https://github.com/vlucas/phpdotenv/security/policy).
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
## License
|
|
362
|
-
|
|
363
|
-
PHP dotenv is licensed under [The BSD 3-Clause License](LICENSE).
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
## For Enterprise
|
|
367
|
-
|
|
368
|
-
Available as part of the Tidelift Subscription
|
|
369
|
-
|
|
370
|
-
The maintainers of `vlucas/phpdotenv` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-vlucas-phpdotenv?utm_source=packagist-vlucas-phpdotenv&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
# Upgrading Guide
|
|
2
|
-
|
|
3
|
-
## V5.5 to V5.6
|
|
4
|
-
|
|
5
|
-
Bumping the minimum required PHP version is not a breaking change, however it is notable. Since version 5.6.0, we now require PHP 7.2.5 or higher. Installation metrics show that for some time, PHP 7.1 has represented only around 0.1% of installs of V5.
|
|
6
|
-
|
|
7
|
-
Release notes for 5.6.0 are available [here](https://github.com/vlucas/phpdotenv/releases/tag/v5.6.0).
|
|
8
|
-
|
|
9
|
-
## V4 to V5
|
|
10
|
-
|
|
11
|
-
### Introduction
|
|
12
|
-
|
|
13
|
-
Version 5 bumps to PHP 7.1+, and adds some additional parameter typing. There have been some internal changes and refactorings too, but nothing that changes the overall feel and usage of the package. The Dotenv class itself is largely unchanged from V4.
|
|
14
|
-
|
|
15
|
-
Release notes for 5.0.0 are available [here](https://github.com/vlucas/phpdotenv/releases/tag/v5.0.0).
|
|
16
|
-
|
|
17
|
-
### Details
|
|
18
|
-
|
|
19
|
-
1. The `Dotenv\Dotenv::createImmutable` and `Dotenv\Dotenv::createMutable` methods no longer call will result in `getenv` and `putenv` being called. One should instead use `Dotenv\Dotenv::createUnsafeImmutable` and `Dotenv\Dotenv::createUnsafeMutable` methods, if one really needs these functions.
|
|
20
|
-
2. The `Dotenv\Dotenv` constructor has been modified to expect exactly 4 parameters: a store, a parser, a loader, and a repository. This likely won't affect many people, since it is more common to construct this class via the public static create methods. Those methods have not changed.
|
|
21
|
-
3. Scalar typehints have been added to the public interface.
|
|
22
|
-
4. The parser now returns a result type instead of raising an exception. This change is strictly internal, and most users won't notice a difference. The responsibility for raising an exception has simply been shifted up to the caller.
|
|
23
|
-
5. Adapters have been refactored again, with changes to the repositories. In particular, the repository builder has been tweaked. It now expects to be explicitly told if you want to use the default adapters or not, and expects individual readers and writers to be added, one by one. Similar changes have been applied to the store factory. Moreover, the `ApacheAdapter` has been changed so that it behaves much like the other adapters. The old behaviour can be simulated by composing it with the new `ReplacingWriter` (see below). We will no longer include this adapter in our default setup, so that people can enable exactly what they need. Finally, by default, we will no longer be using the `PutenvAdapter`. It can be added, as required.
|
|
24
|
-
6. Variable whitelisting has been replaced with allow listing, and the responsibility has moved from the loader to a new adapter `GuardedWriter`.
|
|
25
|
-
7. The parser has been moved to its own namespace and parses entire files now. This change is expected to have little impact when upgrading. The `Lines` class has also moved to the parser namespace.
|
|
26
|
-
8. The loader now only returns the variables that were actually loaded into the repository, and not all the variables from the file. Moreover, it now expects as input the result of running the new parser (an array of entries), rather than raw file content.
|
|
27
|
-
|
|
28
|
-
The changes listed in (4) mean that instead of:
|
|
29
|
-
|
|
30
|
-
```php
|
|
31
|
-
$repository = Dotenv\Repository\RepositoryBuilder::create()
|
|
32
|
-
->withReaders([
|
|
33
|
-
new Dotenv\Repository\Adapter\EnvConstAdapter(),
|
|
34
|
-
])
|
|
35
|
-
->withWriters([
|
|
36
|
-
new Dotenv\Repository\Adapter\EnvConstAdapter(),
|
|
37
|
-
new Dotenv\Repository\Adapter\PutenvAdapter(),
|
|
38
|
-
])
|
|
39
|
-
->make();
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
one would now write:
|
|
43
|
-
|
|
44
|
-
```php
|
|
45
|
-
$repository = Dotenv\Repository\RepositoryBuilder::createWithNoAdapters()
|
|
46
|
-
->addAdapter(Dotenv\Repository\Adapter\EnvConstAdapter::class)
|
|
47
|
-
->addWriter(Dotenv\Repository\Adapter\PutenvAdapter::class)
|
|
48
|
-
->make();
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Instead of passing class names, one can also pass actual adapter instances. Note that it is not possible to directly construct any of the adapters. One has to go via their static `create` method which returns an optional. This is to strictly encapsulate the fact that not all adapters are capable of running on all systems, and so those that cannot be run, cannot be created. For example, the apache adapter can only be run within an apache web server context. Passing the class names as in the above example will handle this for you, by adding the adapter only if it can be created (the optional has a value set).
|
|
52
|
-
|
|
53
|
-
To add an apache environment variable writer that only writes to existing apache environment variables, as was the default in v4, one should do the following:
|
|
54
|
-
|
|
55
|
-
```php
|
|
56
|
-
$builder = Dotenv\Repository\RepositoryBuilder::createWithDefaultAdapters();
|
|
57
|
-
|
|
58
|
-
Dotenv\Repository\Adapter\ApacheAdapter::create()->map(function ($adapter) {
|
|
59
|
-
return new Dotenv\Repository\Adapter\ReplacingWriter($adapter, $adapter);
|
|
60
|
-
})->map([$builder, 'addWriter'])->getOrElse($builder);
|
|
61
|
-
|
|
62
|
-
$repository = $builder->make();
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
The use of optionals handles the case where the apache environment functions are not available (such as in a CLI environment).
|
|
66
|
-
|
|
67
|
-
## V4.0 to V4.1
|
|
68
|
-
|
|
69
|
-
### Introduction
|
|
70
|
-
|
|
71
|
-
Version 4.1 is a minor release, and as such, there are no breaking changes. There is, however a deprecation to be noted.
|
|
72
|
-
|
|
73
|
-
### Details
|
|
74
|
-
|
|
75
|
-
The `Dotenv\Dotenv` constructor now expects either an array of file paths as the third parameter, or an instance of `Dotenv\Store\StoreInterface`. Passing an array is deprecated, and will be removed in V5.
|
|
76
|
-
|
|
77
|
-
## V3 to V4
|
|
78
|
-
|
|
79
|
-
### Introduction
|
|
80
|
-
|
|
81
|
-
Version 4 sees some refactoring, and support for escaping dollars in values (https://github.com/vlucas/phpdotenv/pull/380). It is no longer possible to change immutability on the fly, and the `Loader` no longer is responsible for tracking immutability. It is now the responsibility of "repositories" to track this. One must explicitly decide if they want (im)mutability when constructing an instance of `Dotenv\Dotenv`.
|
|
82
|
-
|
|
83
|
-
Release notes for 4.0.0 are available [here](https://github.com/vlucas/phpdotenv/releases/tag/v4.0.0).
|
|
84
|
-
|
|
85
|
-
### Details
|
|
86
|
-
|
|
87
|
-
V4 has again changed the way you initialize the `Dotenv` class. If you want immutable loading of environment variables, then replace `Dotenv::create` with `Dotenv::createImmutable`, and if you want mutable loading, replace `Dotenv::create` with `Dotenv::createMutable` and `->overload()` with `->load()`. The `overload` method has been removed in favour of specifying mutability at object construction.
|
|
88
|
-
|
|
89
|
-
The behaviour when parsing single quoted strings has now changed, to mimic the behaviour of bash. It is no longer possible to escape characters in single quoted strings, and everything is treated literally. As soon as the first single quote character is read, after the initial one, then the variable is treated as ending immediately at that point. When parsing unquoted or double quoted strings, it is now possible to escape dollar signs, to forcefully avoid variable interpolation. Escaping dollars is not mandated, in the sense that if a dollar is present, and not following by variable interpolation syntax, this is allowed, and the dollar will be treated as a literal dollar. Finally, interpolation of variables is now performed right to left, instead of left to right, so it is possible to nest interpolations to allow using the value of a variable as the name of another for further interpolation.
|
|
90
|
-
|
|
91
|
-
The `getEnvironmentVariableNames` method is no longer available. This is because calls to `load()` (since v3.0.0) return an associative array of what was loaded, so `$dotenv->getEnvironmentVariableNames()` can be replaced with `array_keys($dotenv->load())`.
|
|
92
|
-
|
|
93
|
-
There have been various internal refactorings. Apart from what has already been mentioned, the only other changes likely to affect developers is:
|
|
94
|
-
|
|
95
|
-
1. The `Dotenv\Environment` namespace has been moved to `Dotenv\Repository`, the `Dotenv\Environment\Adapter\AdapterInterface` interface has been replaced by `Dotenv\Repository\Adapter\ReaderInterface` and `Dotenv\Repository\Adapter\WriterInterface`.
|
|
96
|
-
2. The `Dotenv\Environment\DotenvFactory` has been (roughly) replaced by `Dotenv\Repository\RepositoryBuilder`, and `Dotenv\Environment\FactoryInterface` has been deleted.
|
|
97
|
-
3. `Dotenv\Environment\AbstractVariables` has been replaced by `Dotenv\Repository\AbstractRepository`, `Dotenv\Environment\DotenvVariables` has been replaced by `Dotenv\Repository\AdapterRepository`, and `Dotenv\Environment\VariablesInterface` has been replaced by `Dotenv\Repository\RepositoryInterface`.
|
|
98
|
-
4. The `Dotenv\Loader` class has been moved to `Dotenv\Loader\Loader`, and now has a different public interface. It no longer expects any parameters at construction, and implements only the new interface `Dotenv\Loader\LoaderInterface`. Its responsibility has changed to purely taking raw env file content, and handing it off to the parser, dealing with variable interpolation, and sending off instructions to the repository to set variables. No longer can it be used as a way to read the environment by callers, and nor does it track immutability.
|
|
99
|
-
5. The `Dotenv\Parser` and `Dotenv\Lines` classes have moved to `Dotenv\Loader\Parser` and `Dotenv\Loader\Lines`, respectively. `Dotenv\Loader\Parser::parse` now return has either `null` or `Dotenv\Loader\Value` objects as values, instead of `string`s. This is to support the new variable interpolation and dollar escaping features.
|
|
100
|
-
6. The `Dotenv\Validator` constructor has changed from `__construct(array $variables, Loader $loader, $required = true)` to `__construct(RepositoryInterface $repository, array $variables, $required = true)`.
|
|
101
|
-
|
|
102
|
-
The example at the bottom of the below upgrading guide, in V4 now looks like:
|
|
103
|
-
|
|
104
|
-
```php
|
|
105
|
-
<?php
|
|
106
|
-
|
|
107
|
-
use Dotenv\Dotenv;
|
|
108
|
-
use Dotenv\Repository\Adapter\EnvConstAdapter;
|
|
109
|
-
use Dotenv\Repository\Adapter\ServerConstAdapter;
|
|
110
|
-
use Dotenv\Repository\RepositoryBuilder;
|
|
111
|
-
|
|
112
|
-
$adapters = [
|
|
113
|
-
new EnvConstAdapter(),
|
|
114
|
-
new ServerConstAdapter(),
|
|
115
|
-
];
|
|
116
|
-
|
|
117
|
-
$repository = RepositoryBuilder::create()
|
|
118
|
-
->withReaders($adapters)
|
|
119
|
-
->withWriters($adapters)
|
|
120
|
-
->immutable()
|
|
121
|
-
->make();
|
|
122
|
-
|
|
123
|
-
Dotenv::create($repository, $path, null)->load();
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
Since v3.2.0, it was easily possible to read a file and process variable interpolations, without actually "loading" the variables. This is still possible in v4.0.0. Example code that does this is as follows:
|
|
127
|
-
|
|
128
|
-
```php
|
|
129
|
-
<?php
|
|
130
|
-
|
|
131
|
-
use Dotenv\Repository\Adapter\ArrayAdapter;
|
|
132
|
-
use Dotenv\Repository\RepositoryBuilder;
|
|
133
|
-
use Dotenv\Loader\Loader;
|
|
134
|
-
|
|
135
|
-
$adapters = [new ArrayAdapter()];
|
|
136
|
-
|
|
137
|
-
$repository = RepositoryBuilder::create()
|
|
138
|
-
->withReaders($adapters)
|
|
139
|
-
->withWriters($adapters)
|
|
140
|
-
->make();
|
|
141
|
-
|
|
142
|
-
$variables = (new Loader())->load($repository, $content);
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
Notice, that compared to v3, the loader no longer expects file paths in the constructor. Reading of the files is now managed by the `Dotenv\Dotenv` class. The loader is genuinely just loading the content into the repository.
|
|
146
|
-
|
|
147
|
-
Finally, we note that the minimum supported version of PHP has increased to 5.5.9, up from 5.4.0 in V3 and 5.3.9 in V2.
|
|
148
|
-
|
|
149
|
-
## V2 to V3
|
|
150
|
-
|
|
151
|
-
### Introduction
|
|
152
|
-
|
|
153
|
-
New in Version 3 is first-class support for multiline variables ([#301](https://github.com/vlucas/phpdotenv/pull/301)) and much more flexibility in terms of which parts of the environment we try to read and modify ([#300](https://github.com/vlucas/phpdotenv/pull/300)). Consequently, you will need to replace any occurrences of `new Dotenv(...)` with `Dotenv::create(...)`, since our new native constructor takes a `Loader` instance now, so that it can be truly customized if required. Finally, one should note that the loader will no longer be trimming values ([#302](https://github.com/vlucas/phpdotenv/pull/302)), moreover `Loader::load()` and its callers now return an associative array of the variables loaded with their values, rather than an array of raw lines from the environment file ([#306](https://github.com/vlucas/phpdotenv/pull/306)).
|
|
154
|
-
|
|
155
|
-
Release notes for 3.0.0 are available [here](https://github.com/vlucas/phpdotenv/releases/tag/v3.0.0).
|
|
156
|
-
|
|
157
|
-
### Details
|
|
158
|
-
|
|
159
|
-
V3 has changed the way you initialize the `Dotenv` class. Consequently, you will need to replace any occurrences of new Dotenv(...) with Dotenv::create(...), since our new native constructor takes a `Loader` instance now.
|
|
160
|
-
|
|
161
|
-
`Loader::load()` and its callers now return an associative array of the variables loaded with their values.
|
|
162
|
-
|
|
163
|
-
Value parsing has been modified in the following ways:
|
|
164
|
-
|
|
165
|
-
1. For unquoted strings, as soon as there's a hash, it's treated as a comment start.
|
|
166
|
-
2. We're being stricter about invalid escape sequences within quoted strings.
|
|
167
|
-
3. We're no longer trimming the parsed values of quoted strings.
|
|
168
|
-
4. Multiline quoted values are now permitted, and will be parsed by V3.
|
|
169
|
-
|
|
170
|
-
| input value | V2.5.2 | V2.6.1 | V3.3.1 |
|
|
171
|
-
|-|-|-|-|
|
|
172
|
-
| `foo#bar` | `foo#bar` | `foo#bar` | `foo` |
|
|
173
|
-
| `foo # bar` | `foo` | `foo` | `foo` |
|
|
174
|
-
| `"iiiiviiiixiiiiviiii\n"` | silent failure | `iiiviiiixiiiiviiii\n` | fails with invalid escape sequence exception |
|
|
175
|
-
| `"iiiiviiiixiiiiviiii\\n"` | `iiiiviiiixiiiiviiii\n` | `iiiiviiiixiiiiviiii\n` | `iiiiviiiixiiiiviiii\n` |
|
|
176
|
-
| `"foo\"bar"` | `foo"bar` | `foo"bar` | `foo"bar` |
|
|
177
|
-
| `" foo "` | `foo` with whitespace trimmed | `foo` with whitespace trimmed | `foo` with 2 spaces in front and one after |
|
|
178
|
-
|
|
179
|
-
In double quoted strings, double quotes and backslashes need escaping with a backslash, and in single quoted strings, single quote and backslashes need escaping with a backslash. In v2.5.2, forgetting an escape can lead to odd results due to the regex running out of stack, but this was fixed in 2.6 and 3.3, with 2.6 allowing you to continue after an unescaped backslash, but 3.3 not.
|
|
180
|
-
|
|
181
|
-
It's possible to use phpdotenv V3 in a threaded environment, instructing it to not call any functions that are not tread-safe:
|
|
182
|
-
|
|
183
|
-
```php
|
|
184
|
-
<?php
|
|
185
|
-
|
|
186
|
-
use Dotenv\Dotenv;
|
|
187
|
-
use Dotenv\Environment\Adapter\EnvConstAdapter;
|
|
188
|
-
use Dotenv\Environment\Adapter\ServerConstAdapter;
|
|
189
|
-
use Dotenv\Environment\DotenvFactory;
|
|
190
|
-
|
|
191
|
-
$factory = new DotenvFactory([new EnvConstAdapter(), new ServerConstAdapter()]);
|
|
192
|
-
|
|
193
|
-
Dotenv::create($path, null, $factory)->load();
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
Finally, we note that the minimum supported version of PHP has increased from 5.3.9 to 5.4.0.
|