create-berna-stencil 2.6.0 → 2.6.2
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/README.md +1 -1
- package/_tools/assistant.js +92 -88
- package/_tools/modules/constants.js +23 -0
- package/_tools/modules/pageComponents.js +77 -0
- package/_tools/modules/updateData.js +25 -44
- package/_tools/modules/updateOutputPath.js +59 -63
- package/_tools/modules/updatePage.js +131 -104
- package/_tools/modules/utils.js +16 -19
- package/_tools/modules/validation.js +20 -0
- package/bin/create.js +74 -12
- package/out/.htaccess +16 -0
- package/out/404.html +163 -0
- package/out/assets/brand/favicon.svg +37 -0
- package/out/assets/brand/logo.svg +37 -0
- package/out/backend/.htaccess +7 -0
- package/out/backend/_core/composer.json +5 -0
- package/out/backend/_core/composer.lock +492 -0
- package/out/backend/_core/index.php +148 -0
- package/out/backend/_core/init.php +34 -0
- package/out/backend/_core/modules/RateLimiter.php +31 -0
- package/out/backend/_core/modules/Response.php +49 -0
- package/{src → out}/backend/_core/vendor/composer/autoload_static.php +10 -10
- package/{src → out}/backend/_core/vendor/composer/installed.json +6 -6
- package/{src → out}/backend/_core/vendor/composer/installed.php +2 -2
- package/out/backend/_core/vendor/graham-campbell/result-type/CHANGELOG.md +53 -0
- package/{src → out}/backend/_core/vendor/graham-campbell/result-type/LICENSE +21 -21
- package/out/backend/_core/vendor/graham-campbell/result-type/README.md +42 -0
- package/{src → out}/backend/_core/vendor/graham-campbell/result-type/composer.json +33 -33
- package/out/backend/_core/vendor/graham-campbell/result-type/phpunit.xml.dist +13 -0
- package/{src → out}/backend/_core/vendor/graham-campbell/result-type/src/Error.php +121 -121
- package/{src → out}/backend/_core/vendor/graham-campbell/result-type/src/Result.php +69 -69
- package/{src → out}/backend/_core/vendor/graham-campbell/result-type/src/Success.php +120 -120
- package/out/backend/_core/vendor/graham-campbell/result-type/tests/ResultTest.php +95 -0
- package/{src → out}/backend/_core/vendor/phpoption/phpoption/LICENSE +200 -200
- package/out/backend/_core/vendor/phpoption/phpoption/Makefile +17 -0
- package/out/backend/_core/vendor/phpoption/phpoption/README.md +201 -0
- package/{src → out}/backend/_core/vendor/phpoption/phpoption/composer.json +50 -50
- package/out/backend/_core/vendor/phpoption/phpoption/phpstan-baseline.neon +44 -0
- package/out/backend/_core/vendor/phpoption/phpoption/phpstan.neon.dist +7 -0
- package/out/backend/_core/vendor/phpoption/phpoption/phpunit.xml.dist +13 -0
- package/{src → out}/backend/_core/vendor/phpoption/phpoption/src/PhpOption/LazyOption.php +175 -175
- package/{src → out}/backend/_core/vendor/phpoption/phpoption/src/PhpOption/None.php +136 -136
- package/{src → out}/backend/_core/vendor/phpoption/phpoption/src/PhpOption/Option.php +434 -434
- package/{src → out}/backend/_core/vendor/phpoption/phpoption/src/PhpOption/Some.php +169 -169
- package/out/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/EnsureTest.php +72 -0
- package/out/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/LazyOptionTest.php +357 -0
- package/out/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/NoneTest.php +153 -0
- package/out/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/OptionTest.php +166 -0
- package/out/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/SomeTest.php +194 -0
- package/out/backend/_core/vendor/phpoption/phpoption/tests/bootstrap.php +8 -0
- package/out/backend/_core/vendor/phpoption/phpoption/vendor-bin/phpstan/composer.json +8 -0
- package/{src → out}/backend/_core/vendor/symfony/polyfill-ctype/Ctype.php +232 -232
- package/{src → out}/backend/_core/vendor/symfony/polyfill-ctype/LICENSE +19 -19
- package/{src → out}/backend/_core/vendor/symfony/polyfill-ctype/README.md +12 -12
- package/{src → out}/backend/_core/vendor/symfony/polyfill-ctype/bootstrap.php +50 -50
- package/{src → out}/backend/_core/vendor/symfony/polyfill-ctype/bootstrap80.php +46 -46
- package/{src → out}/backend/_core/vendor/symfony/polyfill-ctype/composer.json +38 -38
- package/{src → out}/backend/_core/vendor/symfony/polyfill-mbstring/LICENSE +19 -19
- package/{src → out}/backend/_core/vendor/symfony/polyfill-mbstring/Mbstring.php +1077 -1077
- package/{src → out}/backend/_core/vendor/symfony/polyfill-mbstring/README.md +13 -13
- package/{src → out}/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php +119 -119
- package/{src → out}/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +1397 -1397
- package/{src → out}/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php +5 -5
- package/{src → out}/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php +1489 -1489
- package/{src → out}/backend/_core/vendor/symfony/polyfill-mbstring/bootstrap.php +171 -171
- package/{src → out}/backend/_core/vendor/symfony/polyfill-mbstring/bootstrap80.php +167 -167
- package/{src → out}/backend/_core/vendor/symfony/polyfill-mbstring/composer.json +39 -39
- package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/LICENSE +19 -19
- package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/Php80.php +115 -115
- package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/PhpToken.php +106 -106
- package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/README.md +25 -25
- package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php +31 -31
- package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php +16 -16
- package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php +20 -20
- package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php +16 -16
- package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php +16 -16
- package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/bootstrap.php +42 -42
- package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/composer.json +37 -37
- package/out/backend/_core/vendor/vlucas/phpdotenv/.editorconfig +15 -0
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/LICENSE +30 -30
- package/out/backend/_core/vendor/vlucas/phpdotenv/Makefile +17 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/README.md +370 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/UPGRADING.md +196 -0
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/composer.json +60 -60
- package/out/backend/_core/vendor/vlucas/phpdotenv/phpstan-baseline.neon +157 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/phpstan.neon.dist +7 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/phpunit.xml.dist +13 -0
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Dotenv.php +267 -267
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php +12 -12
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidEncodingException.php +12 -12
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php +12 -12
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php +12 -12
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Exception/ValidationException.php +12 -12
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Loader/Loader.php +48 -48
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Loader/LoaderInterface.php +20 -20
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Loader/Resolver.php +65 -65
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Entry.php +59 -59
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Parser/EntryParser.php +299 -299
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Lexer.php +58 -58
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Lines.php +127 -127
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Parser.php +53 -53
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Parser/ParserInterface.php +19 -19
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Value.php +88 -88
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/AdapterInterface.php +15 -15
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php +89 -89
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php +80 -80
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php +88 -88
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/GuardedWriter.php +85 -85
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ImmutableWriter.php +110 -110
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiReader.php +48 -48
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiWriter.php +64 -64
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php +91 -91
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php +17 -17
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReplacingWriter.php +104 -104
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php +88 -88
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php +27 -27
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/AdapterRepository.php +107 -107
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php +272 -272
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php +51 -51
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Store/File/Paths.php +44 -44
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Store/File/Reader.php +81 -81
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Store/FileStore.php +72 -72
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php +141 -141
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Store/StoreInterface.php +17 -17
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Store/StringStore.php +37 -37
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Util/Regex.php +112 -112
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Util/Str.php +108 -108
- package/{src → out}/backend/_core/vendor/vlucas/phpdotenv/src/Validator.php +207 -207
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/DotenvTest.php +387 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Loader/LoaderTest.php +86 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/EntryParserTest.php +234 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LexerTest.php +40 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LinesTest.php +53 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/ParserTest.php +98 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ArrayAdapterTest.php +57 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/EnvConstAdapterTest.php +75 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/PutenvAdapterTest.php +52 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ServerConstAdapterTest.php +75 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/RepositoryTest.php +305 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Store/StoreTest.php +141 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/ValidatorTest.php +479 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/.env +5 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/assertions.env +18 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/booleans.env +33 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/commented.env +15 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/empty.env +1 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/example.env +1 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/exported.env +7 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/immutable.env +1 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/integers.env +17 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/large.env +2 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multibyte.env +3 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multiline.env +14 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multiple.env +4 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/mutable.env +1 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/nested.env +15 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/quoted.env +11 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/specialchars.env +8 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/unicodevarnames.env +2 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/utf8-with-bom-encoding.env +3 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/windows.env +1 -0
- package/out/backend/_core/vendor/vlucas/phpdotenv/vendor-bin/phpstan/composer.json +15 -0
- package/out/backend/api/protected/example-protected.php +17 -0
- package/out/backend/api/public/example-public.php +17 -0
- package/out/backend/database/Database.php +24 -0
- package/out/backend/database/migrations/create_example_db.sql +1 -0
- package/out/backend/web.config +17 -0
- package/out/css/fonts/bootstrap-icons.woff +0 -0
- package/out/css/fonts/bootstrap-icons.woff2 +0 -0
- package/out/css/github-markdown-dark.css +1124 -0
- package/out/css/github-markdown-light.css +1124 -0
- package/out/css/pages/404.css +21517 -0
- package/out/css/pages/homepage.css +21508 -0
- package/out/data/site.json +44 -0
- package/out/index.html +1147 -0
- package/out/js/bootstrap.bundle.min.js +7 -0
- package/out/js/pages/js/pages/404.js +6 -0
- package/out/js/pages/js/pages/homepage.js +6 -0
- package/out/js/pages/ts/pages/404.js +6 -0
- package/out/js/pages/ts/pages/homepage.js +6 -0
- package/out/llms.txt +14 -0
- package/out/robots.txt +4 -0
- package/out/sitemap.xml +15 -0
- package/out/web.config +27 -0
- package/package.json +14 -47
- package/src/frontend/data/site.json +1 -1
- package/.gitignore +0 -4
- package/_tools/modules/updateIncludes.js +0 -81
- package/src/backend/config.example.php +0 -28
- /package/{src → out}/backend/_core/vendor/autoload.php +0 -0
- /package/{src → out}/backend/_core/vendor/composer/ClassLoader.php +0 -0
- /package/{src → out}/backend/_core/vendor/composer/InstalledVersions.php +0 -0
- /package/{src → out}/backend/_core/vendor/composer/LICENSE +0 -0
- /package/{src → out}/backend/_core/vendor/composer/autoload_classmap.php +0 -0
- /package/{src → out}/backend/_core/vendor/composer/autoload_files.php +0 -0
- /package/{src → out}/backend/_core/vendor/composer/autoload_namespaces.php +0 -0
- /package/{src → out}/backend/_core/vendor/composer/autoload_psr4.php +0 -0
- /package/{src → out}/backend/_core/vendor/composer/autoload_real.php +0 -0
- /package/{src → out}/backend/_core/vendor/composer/platform_check.php +0 -0
package/{src → out}/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php
RENAMED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* This file is part of the Symfony package.
|
|
5
|
-
*
|
|
6
|
-
* (c) Fabien Potencier <fabien@symfony.com>
|
|
7
|
-
*
|
|
8
|
-
* For the full copyright and license information, please view the LICENSE
|
|
9
|
-
* file that was distributed with this source code.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
if (\PHP_VERSION_ID < 80000) {
|
|
13
|
-
class ValueError extends Error
|
|
14
|
-
{
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* This file is part of the Symfony package.
|
|
5
|
+
*
|
|
6
|
+
* (c) Fabien Potencier <fabien@symfony.com>
|
|
7
|
+
*
|
|
8
|
+
* For the full copyright and license information, please view the LICENSE
|
|
9
|
+
* file that was distributed with this source code.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
if (\PHP_VERSION_ID < 80000) {
|
|
13
|
+
class ValueError extends Error
|
|
14
|
+
{
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* This file is part of the Symfony package.
|
|
5
|
-
*
|
|
6
|
-
* (c) Fabien Potencier <fabien@symfony.com>
|
|
7
|
-
*
|
|
8
|
-
* For the full copyright and license information, please view the LICENSE
|
|
9
|
-
* file that was distributed with this source code.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
use Symfony\Polyfill\Php80 as p;
|
|
13
|
-
|
|
14
|
-
if (\PHP_VERSION_ID >= 80000) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (!defined('FILTER_VALIDATE_BOOL') && defined('FILTER_VALIDATE_BOOLEAN')) {
|
|
19
|
-
define('FILTER_VALIDATE_BOOL', \FILTER_VALIDATE_BOOLEAN);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (!function_exists('fdiv')) {
|
|
23
|
-
function fdiv(float $num1, float $num2): float { return p\Php80::fdiv($num1, $num2); }
|
|
24
|
-
}
|
|
25
|
-
if (!function_exists('preg_last_error_msg')) {
|
|
26
|
-
function preg_last_error_msg(): string { return p\Php80::preg_last_error_msg(); }
|
|
27
|
-
}
|
|
28
|
-
if (!function_exists('str_contains')) {
|
|
29
|
-
function str_contains(?string $haystack, ?string $needle): bool { return p\Php80::str_contains($haystack ?? '', $needle ?? ''); }
|
|
30
|
-
}
|
|
31
|
-
if (!function_exists('str_starts_with')) {
|
|
32
|
-
function str_starts_with(?string $haystack, ?string $needle): bool { return p\Php80::str_starts_with($haystack ?? '', $needle ?? ''); }
|
|
33
|
-
}
|
|
34
|
-
if (!function_exists('str_ends_with')) {
|
|
35
|
-
function str_ends_with(?string $haystack, ?string $needle): bool { return p\Php80::str_ends_with($haystack ?? '', $needle ?? ''); }
|
|
36
|
-
}
|
|
37
|
-
if (!function_exists('get_debug_type')) {
|
|
38
|
-
function get_debug_type($value): string { return p\Php80::get_debug_type($value); }
|
|
39
|
-
}
|
|
40
|
-
if (!function_exists('get_resource_id')) {
|
|
41
|
-
function get_resource_id($resource): int { return p\Php80::get_resource_id($resource); }
|
|
42
|
-
}
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* This file is part of the Symfony package.
|
|
5
|
+
*
|
|
6
|
+
* (c) Fabien Potencier <fabien@symfony.com>
|
|
7
|
+
*
|
|
8
|
+
* For the full copyright and license information, please view the LICENSE
|
|
9
|
+
* file that was distributed with this source code.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
use Symfony\Polyfill\Php80 as p;
|
|
13
|
+
|
|
14
|
+
if (\PHP_VERSION_ID >= 80000) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!defined('FILTER_VALIDATE_BOOL') && defined('FILTER_VALIDATE_BOOLEAN')) {
|
|
19
|
+
define('FILTER_VALIDATE_BOOL', \FILTER_VALIDATE_BOOLEAN);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!function_exists('fdiv')) {
|
|
23
|
+
function fdiv(float $num1, float $num2): float { return p\Php80::fdiv($num1, $num2); }
|
|
24
|
+
}
|
|
25
|
+
if (!function_exists('preg_last_error_msg')) {
|
|
26
|
+
function preg_last_error_msg(): string { return p\Php80::preg_last_error_msg(); }
|
|
27
|
+
}
|
|
28
|
+
if (!function_exists('str_contains')) {
|
|
29
|
+
function str_contains(?string $haystack, ?string $needle): bool { return p\Php80::str_contains($haystack ?? '', $needle ?? ''); }
|
|
30
|
+
}
|
|
31
|
+
if (!function_exists('str_starts_with')) {
|
|
32
|
+
function str_starts_with(?string $haystack, ?string $needle): bool { return p\Php80::str_starts_with($haystack ?? '', $needle ?? ''); }
|
|
33
|
+
}
|
|
34
|
+
if (!function_exists('str_ends_with')) {
|
|
35
|
+
function str_ends_with(?string $haystack, ?string $needle): bool { return p\Php80::str_ends_with($haystack ?? '', $needle ?? ''); }
|
|
36
|
+
}
|
|
37
|
+
if (!function_exists('get_debug_type')) {
|
|
38
|
+
function get_debug_type($value): string { return p\Php80::get_debug_type($value); }
|
|
39
|
+
}
|
|
40
|
+
if (!function_exists('get_resource_id')) {
|
|
41
|
+
function get_resource_id($resource): int { return p\Php80::get_resource_id($resource); }
|
|
42
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "symfony/polyfill-php80",
|
|
3
|
-
"type": "library",
|
|
4
|
-
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
|
|
5
|
-
"keywords": ["polyfill", "shim", "compatibility", "portable"],
|
|
6
|
-
"homepage": "https://symfony.com",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"authors": [
|
|
9
|
-
{
|
|
10
|
-
"name": "Ion Bazan",
|
|
11
|
-
"email": "ion.bazan@gmail.com"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"name": "Nicolas Grekas",
|
|
15
|
-
"email": "p@tchwork.com"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"name": "Symfony Community",
|
|
19
|
-
"homepage": "https://symfony.com/contributors"
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
"require": {
|
|
23
|
-
"php": ">=7.2"
|
|
24
|
-
},
|
|
25
|
-
"autoload": {
|
|
26
|
-
"psr-4": { "Symfony\\Polyfill\\Php80\\": "" },
|
|
27
|
-
"files": [ "bootstrap.php" ],
|
|
28
|
-
"classmap": [ "Resources/stubs" ]
|
|
29
|
-
},
|
|
30
|
-
"minimum-stability": "dev",
|
|
31
|
-
"extra": {
|
|
32
|
-
"thanks": {
|
|
33
|
-
"name": "symfony/polyfill",
|
|
34
|
-
"url": "https://github.com/symfony/polyfill"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "symfony/polyfill-php80",
|
|
3
|
+
"type": "library",
|
|
4
|
+
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
|
|
5
|
+
"keywords": ["polyfill", "shim", "compatibility", "portable"],
|
|
6
|
+
"homepage": "https://symfony.com",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"authors": [
|
|
9
|
+
{
|
|
10
|
+
"name": "Ion Bazan",
|
|
11
|
+
"email": "ion.bazan@gmail.com"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "Nicolas Grekas",
|
|
15
|
+
"email": "p@tchwork.com"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "Symfony Community",
|
|
19
|
+
"homepage": "https://symfony.com/contributors"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"require": {
|
|
23
|
+
"php": ">=7.2"
|
|
24
|
+
},
|
|
25
|
+
"autoload": {
|
|
26
|
+
"psr-4": { "Symfony\\Polyfill\\Php80\\": "" },
|
|
27
|
+
"files": [ "bootstrap.php" ],
|
|
28
|
+
"classmap": [ "Resources/stubs" ]
|
|
29
|
+
},
|
|
30
|
+
"minimum-stability": "dev",
|
|
31
|
+
"extra": {
|
|
32
|
+
"thanks": {
|
|
33
|
+
"name": "symfony/polyfill",
|
|
34
|
+
"url": "https://github.com/symfony/polyfill"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
BSD 3-Clause License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2014, Graham Campbell.
|
|
4
|
-
Copyright (c) 2013, Vance Lucas.
|
|
5
|
-
All rights reserved.
|
|
6
|
-
|
|
7
|
-
Redistribution and use in source and binary forms, with or without
|
|
8
|
-
modification, are permitted provided that the following conditions are met:
|
|
9
|
-
|
|
10
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
|
11
|
-
list of conditions and the following disclaimer.
|
|
12
|
-
|
|
13
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
-
this list of conditions and the following disclaimer in the documentation
|
|
15
|
-
and/or other materials provided with the distribution.
|
|
16
|
-
|
|
17
|
-
3. Neither the name of the copyright holder nor the names of its
|
|
18
|
-
contributors may be used to endorse or promote products derived from
|
|
19
|
-
this software without specific prior written permission.
|
|
20
|
-
|
|
21
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
22
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
23
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
24
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
25
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
26
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
27
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
28
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
29
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014, Graham Campbell.
|
|
4
|
+
Copyright (c) 2013, Vance Lucas.
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
Redistribution and use in source and binary forms, with or without
|
|
8
|
+
modification, are permitted provided that the following conditions are met:
|
|
9
|
+
|
|
10
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
11
|
+
list of conditions and the following disclaimer.
|
|
12
|
+
|
|
13
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
and/or other materials provided with the distribution.
|
|
16
|
+
|
|
17
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
18
|
+
contributors may be used to endorse or promote products derived from
|
|
19
|
+
this software without specific prior written permission.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
22
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
23
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
24
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
25
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
26
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
27
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
28
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
29
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
30
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
install:
|
|
2
|
+
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.5-base update
|
|
3
|
+
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.5-base bin all update
|
|
4
|
+
|
|
5
|
+
phpunit:
|
|
6
|
+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit --rm registry.gitlab.com/grahamcampbell/php:8.5-cli
|
|
7
|
+
|
|
8
|
+
phpstan-analyze:
|
|
9
|
+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.5-cli analyze
|
|
10
|
+
|
|
11
|
+
phpstan-baseline:
|
|
12
|
+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.5-cli analyze --generate-baseline
|
|
13
|
+
|
|
14
|
+
test: phpunit phpstan-analyze
|
|
15
|
+
|
|
16
|
+
clean:
|
|
17
|
+
@rm -rf .phpunit.result.cache composer.lock vendor vendor-bin/*/composer.lock vendor-bin/*/vendor
|
|
@@ -0,0 +1,370 @@
|
|
|
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)
|