init
This commit is contained in:
50
backend/vendor/symfony/dotenv/CHANGELOG.md
vendored
Normal file
50
backend/vendor/symfony/dotenv/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
7.1
|
||||
---
|
||||
|
||||
* Add `SYMFONY_DOTENV_PATH` variable with the path to the `.env` file loaded by `Dotenv::loadEnv()` or `Dotenv::bootEnv()`
|
||||
|
||||
6.2
|
||||
---
|
||||
|
||||
* Add a new `filter` argument to `debug:dotenv` command to filter variable names
|
||||
|
||||
5.4
|
||||
---
|
||||
|
||||
* Add `dotenv:dump` command to compile the contents of the .env files into a PHP-optimized file called `.env.local.php`
|
||||
* Add `debug:dotenv` command to list all dotenv files with variables and values
|
||||
* Add `$overrideExistingVars` on `Dotenv::bootEnv()` and `Dotenv::loadEnv()`
|
||||
|
||||
5.1.0
|
||||
-----
|
||||
|
||||
* added `Dotenv::bootEnv()` to check for `.env.local.php` before calling `Dotenv::loadEnv()`
|
||||
* added `Dotenv::setProdEnvs()` and `Dotenv::usePutenv()`
|
||||
* made Dotenv's constructor accept `$envKey` and `$debugKey` arguments, to define
|
||||
the name of the env vars that configure the env name and debug settings
|
||||
* deprecated passing `$usePutenv` argument to Dotenv's constructor
|
||||
|
||||
5.0.0
|
||||
-----
|
||||
|
||||
* using `putenv()` is disabled by default
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
* deprecated use of `putenv()` by default. This feature will be opted-in with a constructor argument to `Dotenv`
|
||||
|
||||
4.2.0
|
||||
-----
|
||||
|
||||
* added `Dotenv::overload()` and `$overrideExistingVars` as optional parameter of `Dotenv::populate()`
|
||||
* added `Dotenv::loadEnv()` to load a .env file and its corresponding .env.local, .env.$env and .env.$env.local files if they exist
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
* [BC BREAK] Since v3.3.7, the latest Dotenv files override the previous ones. Real env vars are not affected and are not overridden.
|
||||
* added the component
|
||||
227
backend/vendor/symfony/dotenv/Command/DebugCommand.php
vendored
Normal file
227
backend/vendor/symfony/dotenv/Command/DebugCommand.php
vendored
Normal file
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Dotenv\Command;
|
||||
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Completion\CompletionInput;
|
||||
use Symfony\Component\Console\Completion\CompletionSuggestions;
|
||||
use Symfony\Component\Console\Formatter\OutputFormatter;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
|
||||
/**
|
||||
* A console command to debug current dotenv files with variables and values.
|
||||
*
|
||||
* @author Christopher Hertel <mail@christopher-hertel.de>
|
||||
*/
|
||||
#[AsCommand(name: 'debug:dotenv', description: 'List all dotenv files with variables and values')]
|
||||
final class DebugCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @deprecated since Symfony 6.1
|
||||
*/
|
||||
protected static $defaultName = 'debug:dotenv';
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 6.1
|
||||
*/
|
||||
protected static $defaultDescription = 'List all dotenv files with variables and values';
|
||||
|
||||
public function __construct(
|
||||
private string $kernelEnvironment,
|
||||
private string $projectDir,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->setDefinition([
|
||||
new InputArgument('filter', InputArgument::OPTIONAL, 'The name of an environment variable or a filter.', null, $this->getAvailableVars(...)),
|
||||
])
|
||||
->setHelp(<<<'EOT'
|
||||
The <info>%command.full_name%</info> command displays all the environment variables configured by dotenv:
|
||||
|
||||
<info>php %command.full_name%</info>
|
||||
|
||||
To get specific variables, specify its full or partial name:
|
||||
|
||||
<info>php %command.full_name% FOO_BAR</info>
|
||||
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
$io->title('Dotenv Variables & Files');
|
||||
|
||||
if (!\array_key_exists('SYMFONY_DOTENV_VARS', $_SERVER)) {
|
||||
$io->error('Dotenv component is not initialized.');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
$dotenvPath = $this->getDotenvPath();
|
||||
|
||||
$envFiles = $this->getEnvFiles($dotenvPath);
|
||||
$availableFiles = array_filter($envFiles, 'is_file');
|
||||
|
||||
if (\in_array(\sprintf('%s.local.php', $dotenvPath), $availableFiles, true)) {
|
||||
$io->warning(\sprintf('Due to existing dump file (%s.local.php) all other dotenv files are skipped.', $this->getRelativeName($dotenvPath)));
|
||||
}
|
||||
|
||||
if (is_file($dotenvPath) && is_file(\sprintf('%s.dist', $dotenvPath))) {
|
||||
$io->warning(\sprintf('The file %s.dist gets skipped due to the existence of %1$s.', $this->getRelativeName($dotenvPath)));
|
||||
}
|
||||
|
||||
$io->section('Scanned Files (in descending priority)');
|
||||
$io->listing(array_map(fn (string $envFile) => \in_array($envFile, $availableFiles, true)
|
||||
? \sprintf('<fg=green>✓</> %s', $this->getRelativeName($envFile))
|
||||
: \sprintf('<fg=red>⨯</> %s', $this->getRelativeName($envFile)), $envFiles));
|
||||
|
||||
$nameFilter = $input->getArgument('filter');
|
||||
$variables = $this->getVariables($availableFiles, $nameFilter);
|
||||
|
||||
$io->section('Variables');
|
||||
|
||||
if ($variables || null === $nameFilter) {
|
||||
$io->table(
|
||||
array_merge(['Variable', 'Value'], array_map($this->getRelativeName(...), $availableFiles)),
|
||||
$variables
|
||||
);
|
||||
|
||||
$io->comment('Note that values might be different between web and CLI.');
|
||||
} else {
|
||||
$io->warning(\sprintf('No variables match the given filter "%s".', $nameFilter));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
|
||||
{
|
||||
if ($input->mustSuggestArgumentValuesFor('filter')) {
|
||||
$suggestions->suggestValues($this->getAvailableVars());
|
||||
}
|
||||
}
|
||||
|
||||
private function getVariables(array $envFiles, ?string $nameFilter): array
|
||||
{
|
||||
$variables = [];
|
||||
$fileValues = [];
|
||||
$dotenvVars = array_flip(explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? ''));
|
||||
|
||||
foreach ($envFiles as $envFile) {
|
||||
$fileValues[$envFile] = $this->loadValues($envFile);
|
||||
$variables += $fileValues[$envFile];
|
||||
}
|
||||
|
||||
foreach ($variables as $var => $varDetails) {
|
||||
if (null !== $nameFilter && 0 !== stripos($var, $nameFilter)) {
|
||||
unset($variables[$var]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$realValue = $_SERVER[$var] ?? '';
|
||||
$varDetails = [$var, '<fg=green>'.OutputFormatter::escape($realValue).'</>'];
|
||||
$varSeen = !isset($dotenvVars[$var]);
|
||||
|
||||
foreach ($envFiles as $envFile) {
|
||||
if (null === $value = $fileValues[$envFile][$var] ?? null) {
|
||||
$varDetails[] = '<fg=yellow>n/a</>';
|
||||
continue;
|
||||
}
|
||||
|
||||
$shortenedValue = OutputFormatter::escape($this->getHelper('formatter')->truncate($value, 30));
|
||||
$varDetails[] = $value === $realValue && !$varSeen ? '<fg=green>'.$shortenedValue.'</>' : $shortenedValue;
|
||||
$varSeen = $varSeen || $value === $realValue;
|
||||
}
|
||||
|
||||
$variables[$var] = $varDetails;
|
||||
}
|
||||
|
||||
ksort($variables);
|
||||
|
||||
return $variables;
|
||||
}
|
||||
|
||||
private function getAvailableVars(): array
|
||||
{
|
||||
$envFiles = $this->getEnvFiles($this->getDotenvPath());
|
||||
|
||||
return array_keys($this->getVariables(array_filter($envFiles, 'is_file'), null));
|
||||
}
|
||||
|
||||
private function getDotenvPath(): string
|
||||
{
|
||||
$config = [];
|
||||
$projectDir = $this->projectDir;
|
||||
|
||||
if (is_file($projectDir)) {
|
||||
$config = ['dotenv_path' => basename($projectDir)];
|
||||
$projectDir = \dirname($projectDir);
|
||||
}
|
||||
|
||||
$composerFile = $projectDir.'/composer.json';
|
||||
$config += $_SERVER['APP_RUNTIME_OPTIONS'] ?? (is_file($composerFile) ? json_decode(file_get_contents($composerFile), true) : [])['extra']['runtime'] ?? [];
|
||||
|
||||
return $projectDir.'/'.($config['dotenv_path'] ?? '.env');
|
||||
}
|
||||
|
||||
private function getEnvFiles(string $filePath): array
|
||||
{
|
||||
$files = [
|
||||
\sprintf('%s.local.php', $filePath),
|
||||
\sprintf('%s.%s.local', $filePath, $this->kernelEnvironment),
|
||||
\sprintf('%s.%s', $filePath, $this->kernelEnvironment),
|
||||
];
|
||||
|
||||
if ('test' !== $this->kernelEnvironment) {
|
||||
$files[] = \sprintf('%s.local', $filePath);
|
||||
}
|
||||
|
||||
if (!is_file($filePath) && is_file(\sprintf('%s.dist', $filePath))) {
|
||||
$files[] = \sprintf('%s.dist', $filePath);
|
||||
} else {
|
||||
$files[] = $filePath;
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
private function getRelativeName(string $filePath): string
|
||||
{
|
||||
$projectDir = is_file($this->projectDir) ? \dirname($this->projectDir) : $this->projectDir;
|
||||
|
||||
if (str_starts_with($filePath, $projectDir.'/') || str_starts_with($filePath, $projectDir.\DIRECTORY_SEPARATOR)) {
|
||||
return substr($filePath, \strlen($projectDir) + 1);
|
||||
}
|
||||
|
||||
return basename($filePath);
|
||||
}
|
||||
|
||||
private function loadValues(string $filePath): array
|
||||
{
|
||||
if (str_ends_with($filePath, '.php')) {
|
||||
return include $filePath;
|
||||
}
|
||||
|
||||
return (new Dotenv())->parse(file_get_contents($filePath));
|
||||
}
|
||||
}
|
||||
130
backend/vendor/symfony/dotenv/Command/DotenvDumpCommand.php
vendored
Normal file
130
backend/vendor/symfony/dotenv/Command/DotenvDumpCommand.php
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Dotenv\Command;
|
||||
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
|
||||
/**
|
||||
* A console command to compile .env files into a PHP-optimized file called .env.local.php.
|
||||
*
|
||||
* To use this command, first register it explicitly as a service, e.g in your services.yaml file:
|
||||
*
|
||||
* ```yaml
|
||||
* services:
|
||||
* # [...]
|
||||
* Symfony\Component\Dotenv\Command\DotenvDumpCommand: ~
|
||||
* ```
|
||||
*/
|
||||
#[Autoconfigure(bind: ['$projectDir' => '%kernel.project_dir%', '$defaultEnv' => '%kernel.environment%'])]
|
||||
#[AsCommand(name: 'dotenv:dump', description: 'Compile .env files to .env.local.php')]
|
||||
final class DotenvDumpCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private string $projectDir,
|
||||
private ?string $defaultEnv = null,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->setDefinition([
|
||||
new InputArgument('env', null === $this->defaultEnv ? InputArgument::REQUIRED : InputArgument::OPTIONAL, 'The application environment to dump .env files for - e.g. "prod".'),
|
||||
])
|
||||
->addOption('empty', null, InputOption::VALUE_NONE, 'Ignore the content of .env files')
|
||||
->setHelp(<<<'EOT'
|
||||
The <info>%command.name%</info> command compiles .env files into a PHP-optimized file called .env.local.php.
|
||||
|
||||
<info>%command.full_name%</info>
|
||||
EOT
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$config = [];
|
||||
$dotenvPath = $this->getDotenvPath($config);
|
||||
|
||||
$env = $input->getArgument('env') ?? $this->defaultEnv;
|
||||
$envKey = $config['env_var_name'] ?? 'APP_ENV';
|
||||
|
||||
if ($input->getOption('empty')) {
|
||||
$vars = [$envKey => $env];
|
||||
} else {
|
||||
$vars = $this->loadEnv($dotenvPath, $env, $config);
|
||||
$env = $vars[$envKey];
|
||||
}
|
||||
|
||||
$vars = var_export($vars, true);
|
||||
$vars = <<<EOF
|
||||
<?php
|
||||
|
||||
// This file was generated by running "php bin/console dotenv:dump $env"
|
||||
|
||||
return $vars;
|
||||
|
||||
EOF;
|
||||
file_put_contents($dotenvPath.'.local.php', $vars, \LOCK_EX);
|
||||
|
||||
$output->writeln(\sprintf('Successfully dumped %s files in <info>%1$s.local.php</> for the <info>%s</> environment.', basename($dotenvPath), $env));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function getDotenvPath(array &$config): string
|
||||
{
|
||||
$config = [];
|
||||
$projectDir = $this->projectDir;
|
||||
|
||||
if (is_file($projectDir)) {
|
||||
$config = ['dotenv_path' => basename($projectDir)];
|
||||
$projectDir = \dirname($projectDir);
|
||||
}
|
||||
|
||||
$composerFile = $projectDir.'/composer.json';
|
||||
$config += $_SERVER['APP_RUNTIME_OPTIONS'] ?? (is_file($composerFile) ? json_decode(file_get_contents($composerFile), true) : [])['extra']['runtime'] ?? [];
|
||||
|
||||
return $projectDir.'/'.($config['dotenv_path'] ?? '.env');
|
||||
}
|
||||
|
||||
private function loadEnv(string $dotenvPath, string $env, array $config): array
|
||||
{
|
||||
$envKey = $config['env_var_name'] ?? 'APP_ENV';
|
||||
$testEnvs = $config['test_envs'] ?? ['test'];
|
||||
|
||||
$dotenv = new Dotenv($envKey);
|
||||
|
||||
$globalsBackup = [$_SERVER, $_ENV];
|
||||
unset($_SERVER[$envKey]);
|
||||
$_ENV = [$envKey => $env];
|
||||
$_SERVER['SYMFONY_DOTENV_VARS'] = implode(',', array_keys($_SERVER));
|
||||
|
||||
try {
|
||||
$dotenv->loadEnv($dotenvPath, null, 'dev', $testEnvs);
|
||||
unset($_ENV['SYMFONY_DOTENV_VARS']);
|
||||
unset($_ENV['SYMFONY_DOTENV_PATH']);
|
||||
|
||||
return $_ENV;
|
||||
} finally {
|
||||
[$_SERVER, $_ENV] = $globalsBackup;
|
||||
}
|
||||
}
|
||||
}
|
||||
668
backend/vendor/symfony/dotenv/Dotenv.php
vendored
Normal file
668
backend/vendor/symfony/dotenv/Dotenv.php
vendored
Normal file
@@ -0,0 +1,668 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Dotenv;
|
||||
|
||||
use Symfony\Component\Dotenv\Exception\ExceptionInterface;
|
||||
use Symfony\Component\Dotenv\Exception\FormatException;
|
||||
use Symfony\Component\Dotenv\Exception\FormatExceptionContext;
|
||||
use Symfony\Component\Dotenv\Exception\PathException;
|
||||
use Symfony\Component\Process\Exception\ExceptionInterface as ProcessException;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/**
|
||||
* Manages .env files.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Kévin Dunglas <dunglas@gmail.com>
|
||||
*/
|
||||
final class Dotenv
|
||||
{
|
||||
public const VARNAME_REGEX = '(?i:_?[A-Z][A-Z0-9_]*+)';
|
||||
public const STATE_VARNAME = 0;
|
||||
public const STATE_VALUE = 1;
|
||||
|
||||
private string $path;
|
||||
private int $cursor;
|
||||
private int $lineno;
|
||||
private string $data;
|
||||
private int $end;
|
||||
private array $values = [];
|
||||
private array $prodEnvs = ['prod'];
|
||||
private bool $usePutenv = false;
|
||||
private bool $resolveVars = true;
|
||||
|
||||
public function __construct(
|
||||
private string $envKey = 'APP_ENV',
|
||||
private string $debugKey = 'APP_DEBUG',
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setProdEnvs(array $prodEnvs): static
|
||||
{
|
||||
$this->prodEnvs = $prodEnvs;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $usePutenv If `putenv()` should be used to define environment variables or not.
|
||||
* Beware that `putenv()` is not thread safe, that's why it's not enabled by default
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function usePutenv(bool $usePutenv = true): static
|
||||
{
|
||||
$this->usePutenv = $usePutenv;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads one or several .env files.
|
||||
*
|
||||
* @param string $path A file to load
|
||||
* @param string ...$extraPaths A list of additional files to load
|
||||
*
|
||||
* @throws FormatException when a file has a syntax error
|
||||
* @throws PathException when a file does not exist or is not readable
|
||||
*/
|
||||
public function load(string $path, string ...$extraPaths): void
|
||||
{
|
||||
if ($extraPaths) {
|
||||
$previousResolveVars = $this->resolveVars;
|
||||
$this->resolveVars = false;
|
||||
try {
|
||||
$this->doLoad(false, \func_get_args());
|
||||
} finally {
|
||||
$this->resolveVars = $previousResolveVars;
|
||||
}
|
||||
$this->resolveLoadedVars();
|
||||
} else {
|
||||
$this->doLoad(false, [$path]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a .env file and the corresponding .env.local, .env.$env and .env.$env.local files if they exist.
|
||||
*
|
||||
* .env.local is always ignored in test env because tests should produce the same results for everyone.
|
||||
* .env.dist is loaded when it exists and .env is not found.
|
||||
*
|
||||
* @param string $path A file to load
|
||||
* @param string|null $envKey The name of the env vars that defines the app env
|
||||
* @param string $defaultEnv The app env to use when none is defined
|
||||
* @param array $testEnvs A list of app envs for which .env.local should be ignored
|
||||
* @param bool $overrideExistingVars Whether existing environment variables set by the system should be overridden
|
||||
*
|
||||
* @throws FormatException when a file has a syntax error
|
||||
* @throws PathException when a file does not exist or is not readable
|
||||
*/
|
||||
public function loadEnv(string $path, ?string $envKey = null, string $defaultEnv = 'dev', array $testEnvs = ['test'], bool $overrideExistingVars = false): void
|
||||
{
|
||||
$this->populatePath($path);
|
||||
|
||||
$previousResolveVars = $this->resolveVars;
|
||||
$this->resolveVars = false;
|
||||
try {
|
||||
$k = $envKey ?? $this->envKey;
|
||||
|
||||
if (is_file($path) || !is_file($p = "$path.dist")) {
|
||||
$this->doLoad($overrideExistingVars, [$path]);
|
||||
} else {
|
||||
$this->doLoad($overrideExistingVars, [$p]);
|
||||
}
|
||||
|
||||
if (null === $env = $_SERVER[$k] ?? $_ENV[$k] ?? null) {
|
||||
$this->populate([$k => $env = $defaultEnv], $overrideExistingVars);
|
||||
}
|
||||
|
||||
if (!\in_array($env, $testEnvs, true) && is_file($p = "$path.local")) {
|
||||
$this->doLoad($overrideExistingVars, [$p]);
|
||||
$env = $_SERVER[$k] ?? $_ENV[$k] ?? $env;
|
||||
}
|
||||
|
||||
if ('local' === $env) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_file($p = "$path.$env")) {
|
||||
$this->doLoad($overrideExistingVars, [$p]);
|
||||
}
|
||||
|
||||
if (is_file($p = "$path.$env.local")) {
|
||||
$this->doLoad($overrideExistingVars, [$p]);
|
||||
}
|
||||
} finally {
|
||||
$this->resolveVars = $previousResolveVars;
|
||||
$this->resolveLoadedVars();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads env vars from .env.local.php if the file exists or from the other .env files otherwise.
|
||||
*
|
||||
* This method also configures the APP_DEBUG env var according to the current APP_ENV.
|
||||
*
|
||||
* See method loadEnv() for rules related to .env files.
|
||||
*/
|
||||
public function bootEnv(string $path, string $defaultEnv = 'dev', array $testEnvs = ['test'], bool $overrideExistingVars = false): void
|
||||
{
|
||||
$p = $path.'.local.php';
|
||||
$env = is_file($p) ? include $p : null;
|
||||
$k = $this->envKey;
|
||||
|
||||
if (\is_array($env) && ($overrideExistingVars || !isset($env[$k]) || ($_SERVER[$k] ?? $_ENV[$k] ?? $env[$k]) === $env[$k])) {
|
||||
$this->populatePath($path);
|
||||
$this->populate($env, $overrideExistingVars);
|
||||
} else {
|
||||
$this->loadEnv($path, $k, $defaultEnv, $testEnvs, $overrideExistingVars);
|
||||
}
|
||||
|
||||
$_SERVER += $_ENV;
|
||||
|
||||
$k = $this->debugKey;
|
||||
$debug = $_SERVER[$k] ?? !\in_array($_SERVER[$this->envKey], $this->prodEnvs, true);
|
||||
$_SERVER[$k] = $_ENV[$k] = (int) $debug || (!\is_bool($debug) && filter_var($debug, \FILTER_VALIDATE_BOOL)) ? '1' : '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads one or several .env files and enables override existing vars.
|
||||
*
|
||||
* @param string $path A file to load
|
||||
* @param string ...$extraPaths A list of additional files to load
|
||||
*
|
||||
* @throws FormatException when a file has a syntax error
|
||||
* @throws PathException when a file does not exist or is not readable
|
||||
*/
|
||||
public function overload(string $path, string ...$extraPaths): void
|
||||
{
|
||||
if ($extraPaths) {
|
||||
$previousResolveVars = $this->resolveVars;
|
||||
$this->resolveVars = false;
|
||||
try {
|
||||
$this->doLoad(true, \func_get_args());
|
||||
} finally {
|
||||
$this->resolveVars = $previousResolveVars;
|
||||
}
|
||||
$this->resolveLoadedVars();
|
||||
} else {
|
||||
$this->doLoad(true, [$path]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets values as environment variables (via putenv, $_ENV, and $_SERVER).
|
||||
*
|
||||
* @param array $values An array of env variables
|
||||
* @param bool $overrideExistingVars Whether existing environment variables set by the system should be overridden
|
||||
*/
|
||||
public function populate(array $values, bool $overrideExistingVars = false): void
|
||||
{
|
||||
$updateLoadedVars = false;
|
||||
$loadedVars = array_flip(explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? $_ENV['SYMFONY_DOTENV_VARS'] ?? ''));
|
||||
|
||||
foreach ($values as $name => $value) {
|
||||
$notHttpName = !str_starts_with($name, 'HTTP_');
|
||||
if (isset($_SERVER[$name]) && $notHttpName && !isset($_ENV[$name])) {
|
||||
$_ENV[$name] = $_SERVER[$name];
|
||||
}
|
||||
|
||||
// don't check existence with getenv() because of thread safety issues
|
||||
if (!isset($loadedVars[$name]) && !$overrideExistingVars && isset($_ENV[$name])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->usePutenv) {
|
||||
putenv("$name=$value");
|
||||
}
|
||||
|
||||
$_ENV[$name] = $value;
|
||||
if ($notHttpName) {
|
||||
$_SERVER[$name] = $value;
|
||||
}
|
||||
|
||||
if (!isset($loadedVars[$name])) {
|
||||
$loadedVars[$name] = $updateLoadedVars = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($updateLoadedVars) {
|
||||
unset($loadedVars['']);
|
||||
$loadedVars = implode(',', array_keys($loadedVars));
|
||||
$_ENV['SYMFONY_DOTENV_VARS'] = $_SERVER['SYMFONY_DOTENV_VARS'] = $loadedVars;
|
||||
|
||||
if ($this->usePutenv) {
|
||||
putenv('SYMFONY_DOTENV_VARS='.$loadedVars);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the contents of an .env file.
|
||||
*
|
||||
* @param string $data The data to be parsed
|
||||
* @param string $path The original file name where data where stored (used for more meaningful error messages)
|
||||
*
|
||||
* @throws FormatException when a file has a syntax error
|
||||
*/
|
||||
public function parse(string $data, string $path = '.env'): array
|
||||
{
|
||||
$this->path = $path;
|
||||
$this->data = str_replace(["\r\n", "\r"], "\n", $data);
|
||||
$this->lineno = 1;
|
||||
$this->cursor = 0;
|
||||
$this->end = \strlen($this->data);
|
||||
$state = self::STATE_VARNAME;
|
||||
$this->values = [];
|
||||
$name = '';
|
||||
|
||||
$this->skipEmptyLines();
|
||||
|
||||
while ($this->cursor < $this->end) {
|
||||
switch ($state) {
|
||||
case self::STATE_VARNAME:
|
||||
$name = $this->lexVarname();
|
||||
$state = self::STATE_VALUE;
|
||||
break;
|
||||
|
||||
case self::STATE_VALUE:
|
||||
$this->values[$name] = $this->lexValue();
|
||||
$state = self::STATE_VARNAME;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (self::STATE_VALUE === $state) {
|
||||
$this->values[$name] = '';
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->values;
|
||||
} finally {
|
||||
$this->values = [];
|
||||
unset($this->path, $this->cursor, $this->lineno, $this->data, $this->end);
|
||||
}
|
||||
}
|
||||
|
||||
private function lexVarname(): string
|
||||
{
|
||||
// var name + optional export
|
||||
if (!preg_match('/(export[ \t]++)?('.self::VARNAME_REGEX.')/A', $this->data, $matches, 0, $this->cursor)) {
|
||||
throw $this->createFormatException('Invalid character in variable name');
|
||||
}
|
||||
$this->moveCursor($matches[0]);
|
||||
|
||||
if ($this->cursor === $this->end || "\n" === $this->data[$this->cursor] || '#' === $this->data[$this->cursor]) {
|
||||
if ($matches[1]) {
|
||||
throw $this->createFormatException('Unable to unset an environment variable');
|
||||
}
|
||||
|
||||
throw $this->createFormatException('Missing = in the environment variable declaration');
|
||||
}
|
||||
|
||||
if (' ' === $this->data[$this->cursor] || "\t" === $this->data[$this->cursor]) {
|
||||
throw $this->createFormatException('Whitespace characters are not supported after the variable name');
|
||||
}
|
||||
|
||||
if ('=' !== $this->data[$this->cursor]) {
|
||||
throw $this->createFormatException('Missing = in the environment variable declaration');
|
||||
}
|
||||
++$this->cursor;
|
||||
|
||||
return $matches[2];
|
||||
}
|
||||
|
||||
private function lexValue(): string
|
||||
{
|
||||
if (preg_match('/[ \t]*+(?:#.*)?$/Am', $this->data, $matches, 0, $this->cursor)) {
|
||||
$this->moveCursor($matches[0]);
|
||||
$this->skipEmptyLines();
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
if (' ' === $this->data[$this->cursor] || "\t" === $this->data[$this->cursor]) {
|
||||
throw $this->createFormatException('Whitespace are not supported before the value');
|
||||
}
|
||||
|
||||
$loadedVars = array_flip(explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? $_ENV['SYMFONY_DOTENV_VARS'] ?? ''));
|
||||
unset($loadedVars['']);
|
||||
$v = '';
|
||||
|
||||
do {
|
||||
if ("'" === $this->data[$this->cursor]) {
|
||||
$len = 0;
|
||||
|
||||
do {
|
||||
if ($this->cursor + ++$len === $this->end) {
|
||||
$this->cursor += $len;
|
||||
|
||||
throw $this->createFormatException('Missing quote to end the value');
|
||||
}
|
||||
} while ("'" !== $this->data[$this->cursor + $len]);
|
||||
|
||||
$singleQuoted = substr($this->data, 1 + $this->cursor, $len - 1);
|
||||
if (!$this->resolveVars) {
|
||||
$singleQuoted = str_replace('$', "\x00", $singleQuoted);
|
||||
}
|
||||
$v .= $singleQuoted;
|
||||
$this->cursor += 1 + $len;
|
||||
} elseif ('"' === $this->data[$this->cursor]) {
|
||||
$value = '';
|
||||
|
||||
if (++$this->cursor === $this->end) {
|
||||
throw $this->createFormatException('Missing quote to end the value');
|
||||
}
|
||||
|
||||
while ('"' !== $this->data[$this->cursor] || ('\\' === $this->data[$this->cursor - 1] && '\\' !== $this->data[$this->cursor - 2])) {
|
||||
$value .= $this->data[$this->cursor];
|
||||
++$this->cursor;
|
||||
|
||||
if ($this->cursor === $this->end) {
|
||||
throw $this->createFormatException('Missing quote to end the value');
|
||||
}
|
||||
}
|
||||
++$this->cursor;
|
||||
$value = str_replace(['\\"', '\r', '\n'], ['"', "\r", "\n"], $value);
|
||||
$resolvedValue = $value;
|
||||
if ($this->resolveVars) {
|
||||
$resolvedValue = $this->resolveCommands($resolvedValue, $loadedVars);
|
||||
$resolvedValue = $this->resolveVariables($resolvedValue, $loadedVars);
|
||||
$resolvedValue = str_replace('\\\\', '\\', $resolvedValue);
|
||||
}
|
||||
$v .= $resolvedValue;
|
||||
} else {
|
||||
$value = '';
|
||||
$prevChr = $this->data[$this->cursor - 1];
|
||||
while ($this->cursor < $this->end && !\in_array($this->data[$this->cursor], ["\n", '"', "'"], true) && !((' ' === $prevChr || "\t" === $prevChr) && '#' === $this->data[$this->cursor])) {
|
||||
if ('\\' === $this->data[$this->cursor] && isset($this->data[$this->cursor + 1]) && ('"' === $this->data[$this->cursor + 1] || "'" === $this->data[$this->cursor + 1])) {
|
||||
++$this->cursor;
|
||||
}
|
||||
|
||||
$value .= $prevChr = $this->data[$this->cursor];
|
||||
|
||||
if ('$' === $this->data[$this->cursor] && isset($this->data[$this->cursor + 1]) && '(' === $this->data[$this->cursor + 1]) {
|
||||
++$this->cursor;
|
||||
$value .= '('.$this->lexNestedExpression().')';
|
||||
}
|
||||
|
||||
++$this->cursor;
|
||||
}
|
||||
$value = rtrim($value);
|
||||
$resolvedValue = $value;
|
||||
if ($this->resolveVars) {
|
||||
$resolvedValue = $this->resolveCommands($resolvedValue, $loadedVars);
|
||||
$resolvedValue = $this->resolveVariables($resolvedValue, $loadedVars);
|
||||
$resolvedValue = str_replace('\\\\', '\\', $resolvedValue);
|
||||
}
|
||||
|
||||
if ($resolvedValue === $value && preg_match('/\s+/', $value) && !str_contains($value, '$')) {
|
||||
throw $this->createFormatException('A value containing spaces must be surrounded by quotes');
|
||||
}
|
||||
|
||||
$v .= $resolvedValue;
|
||||
|
||||
if ($this->cursor < $this->end && '#' === $this->data[$this->cursor]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while ($this->cursor < $this->end && "\n" !== $this->data[$this->cursor]);
|
||||
|
||||
$this->skipEmptyLines();
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
private function lexNestedExpression(): string
|
||||
{
|
||||
++$this->cursor;
|
||||
$value = '';
|
||||
|
||||
while ("\n" !== $this->data[$this->cursor] && ')' !== $this->data[$this->cursor]) {
|
||||
$value .= $this->data[$this->cursor];
|
||||
|
||||
if ('(' === $this->data[$this->cursor]) {
|
||||
$value .= $this->lexNestedExpression().')';
|
||||
}
|
||||
|
||||
++$this->cursor;
|
||||
|
||||
if ($this->cursor === $this->end) {
|
||||
throw $this->createFormatException('Missing closing parenthesis.');
|
||||
}
|
||||
}
|
||||
|
||||
if ("\n" === $this->data[$this->cursor]) {
|
||||
throw $this->createFormatException('Missing closing parenthesis.');
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
private function skipEmptyLines(): void
|
||||
{
|
||||
if (preg_match('/(?:\s*+(?:#[^\n]*+)?+)++/A', $this->data, $match, 0, $this->cursor)) {
|
||||
$this->moveCursor($match[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private function resolveCommands(string $value, array $loadedVars): string
|
||||
{
|
||||
if (!str_contains($value, '$')) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$regex = '/
|
||||
(\\\\)? # escaped with a backslash?
|
||||
\$
|
||||
(?<cmd>
|
||||
\( # require opening parenthesis
|
||||
([^()]|\g<cmd>)+ # allow any number of non-parens, or balanced parens (by nesting the <cmd> expression recursively)
|
||||
\) # require closing paren
|
||||
)
|
||||
/x';
|
||||
|
||||
return preg_replace_callback($regex, function ($matches) use ($loadedVars) {
|
||||
if ('\\' === $matches[1]) {
|
||||
return substr($matches[0], 1);
|
||||
}
|
||||
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
throw new \LogicException('Resolving commands is not supported on Windows.');
|
||||
}
|
||||
|
||||
if (!class_exists(Process::class)) {
|
||||
throw new \LogicException('Resolving commands requires the Symfony Process component. Try running "composer require symfony/process".');
|
||||
}
|
||||
|
||||
$process = Process::fromShellCommandline('echo '.$matches[0]);
|
||||
|
||||
$env = [];
|
||||
foreach ($this->values as $name => $value) {
|
||||
if (isset($loadedVars[$name]) || (!isset($_ENV[$name]) && !(isset($_SERVER[$name]) && !str_starts_with($name, 'HTTP_')))) {
|
||||
$env[$name] = $value;
|
||||
}
|
||||
}
|
||||
$process->setEnv($env);
|
||||
|
||||
try {
|
||||
$process->mustRun();
|
||||
} catch (ProcessException) {
|
||||
throw $this->createFormatException(\sprintf('Issue expanding a command (%s)', $process->getErrorOutput()));
|
||||
}
|
||||
|
||||
return rtrim($process->getOutput(), "\n\r");
|
||||
}, $value);
|
||||
}
|
||||
|
||||
private function resolveVariables(string $value, array $loadedVars): string
|
||||
{
|
||||
if (!str_contains($value, '$')) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$regex = '/
|
||||
(?<!\\\\)
|
||||
(?P<backslashes>\\\\*) # escaped with a backslash?
|
||||
\$
|
||||
(?!\() # no opening parenthesis
|
||||
(?P<opening_brace>\{)? # optional brace
|
||||
(?P<name>'.self::VARNAME_REGEX.')? # var name
|
||||
(?P<default_value>:[-=][^\}]*+)? # optional default value
|
||||
(?P<closing_brace>\})? # optional closing brace
|
||||
/x';
|
||||
|
||||
return preg_replace_callback($regex, function ($matches) use ($loadedVars) {
|
||||
// odd number of backslashes means the $ character is escaped
|
||||
if (1 === \strlen($matches['backslashes']) % 2) {
|
||||
return substr($matches[0], 1);
|
||||
}
|
||||
|
||||
// unescaped $ not followed by variable name
|
||||
if (!isset($matches['name'])) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
if ('{' === $matches['opening_brace'] && !isset($matches['closing_brace'])) {
|
||||
throw $this->createFormatException('Unclosed braces on variable expansion');
|
||||
}
|
||||
|
||||
$name = $matches['name'];
|
||||
if (isset($loadedVars[$name]) && isset($this->values[$name])) {
|
||||
$value = $this->values[$name];
|
||||
} elseif (isset($_ENV[$name])) {
|
||||
$value = $_ENV[$name];
|
||||
} elseif (isset($_SERVER[$name]) && !str_starts_with($name, 'HTTP_')) {
|
||||
$value = $_SERVER[$name];
|
||||
} elseif (isset($this->values[$name])) {
|
||||
$value = $this->values[$name];
|
||||
} else {
|
||||
$value = (string) getenv($name);
|
||||
}
|
||||
|
||||
if ('' === $value && isset($matches['default_value']) && '' !== $matches['default_value']) {
|
||||
$unsupportedChars = strpbrk($matches['default_value'], '\'"{$');
|
||||
if (false !== $unsupportedChars) {
|
||||
throw $this->createFormatException(\sprintf('Unsupported character "%s" found in the default value of variable "$%s".', $unsupportedChars[0], $name));
|
||||
}
|
||||
|
||||
$value = substr($matches['default_value'], 2);
|
||||
|
||||
if ('=' === $matches['default_value'][1]) {
|
||||
$this->values[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$matches['opening_brace'] && isset($matches['closing_brace'])) {
|
||||
$value .= '}';
|
||||
}
|
||||
|
||||
return $matches['backslashes'].$value;
|
||||
}, $value);
|
||||
}
|
||||
|
||||
private function moveCursor(string $text): void
|
||||
{
|
||||
$this->cursor += \strlen($text);
|
||||
$this->lineno += substr_count($text, "\n");
|
||||
}
|
||||
|
||||
private function createFormatException(string $message): FormatException
|
||||
{
|
||||
return new FormatException($message, new FormatExceptionContext($this->data, $this->path, $this->lineno, $this->cursor));
|
||||
}
|
||||
|
||||
private function doLoad(bool $overrideExistingVars, array $paths): void
|
||||
{
|
||||
foreach ($paths as $path) {
|
||||
if (!is_readable($path) || is_dir($path)) {
|
||||
throw new PathException($path);
|
||||
}
|
||||
|
||||
$data = file_get_contents($path);
|
||||
|
||||
if ("\xEF\xBB\xBF" === substr($data, 0, 3)) {
|
||||
throw new FormatException('Loading files starting with a byte-order-mark (BOM) is not supported.', new FormatExceptionContext($data, $path, 1, 0));
|
||||
}
|
||||
|
||||
if (str_contains($data, "\0")) {
|
||||
throw new FormatException('Loading files containing NUL bytes is not supported.', new FormatExceptionContext($data, $path, 1, 0));
|
||||
}
|
||||
|
||||
$this->populate($this->parse($data, $path), $overrideExistingVars);
|
||||
}
|
||||
}
|
||||
|
||||
private function resolveLoadedVars(): void
|
||||
{
|
||||
$loadedVars = array_flip(explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? $_ENV['SYMFONY_DOTENV_VARS'] ?? ''));
|
||||
unset($loadedVars['']);
|
||||
|
||||
$this->values = [];
|
||||
$this->path = '';
|
||||
$this->data = '';
|
||||
$this->lineno = 0;
|
||||
$this->cursor = 0;
|
||||
$this->end = 0;
|
||||
|
||||
for ($pass = 0; $pass < 5; ++$pass) {
|
||||
$resolved = [];
|
||||
foreach ($loadedVars as $name => $_) {
|
||||
if ('SYMFONY_DOTENV_VARS' === $name) {
|
||||
continue;
|
||||
}
|
||||
if (!str_contains($value = $_ENV[$name] ?? '', '$')) {
|
||||
continue;
|
||||
}
|
||||
$resolvedValue = $this->resolveCommands($value, $loadedVars);
|
||||
$resolvedValue = $this->resolveVariables($resolvedValue, $loadedVars);
|
||||
$resolvedValue = str_replace('\\\\', '\\', $resolvedValue);
|
||||
if ($value !== $resolvedValue) {
|
||||
$resolved[$name] = $resolvedValue;
|
||||
}
|
||||
}
|
||||
if (!$resolved) {
|
||||
break;
|
||||
}
|
||||
$this->populate($resolved, true);
|
||||
}
|
||||
if (5 === $pass && $resolved) {
|
||||
throw new class('Too many levels of variable indirection in env vars: '.implode(', ', array_keys($resolved)).'.') extends \LogicException implements ExceptionInterface {};
|
||||
}
|
||||
|
||||
// Restore literal $ signs that were protected from resolution (from single-quoted strings)
|
||||
$restored = [];
|
||||
foreach ($loadedVars as $name => $_) {
|
||||
if ('SYMFONY_DOTENV_VARS' !== $name && str_contains($value = $_ENV[$name] ?? '', "\x00")) {
|
||||
$restored[$name] = str_replace("\x00", '$', $value);
|
||||
}
|
||||
}
|
||||
if ($restored) {
|
||||
$this->populate($restored, true);
|
||||
}
|
||||
|
||||
$this->values = [];
|
||||
unset($this->path, $this->data, $this->lineno, $this->cursor, $this->end);
|
||||
}
|
||||
|
||||
private function populatePath(string $path): void
|
||||
{
|
||||
$_ENV['SYMFONY_DOTENV_PATH'] = $_SERVER['SYMFONY_DOTENV_PATH'] = $path;
|
||||
|
||||
if ($this->usePutenv) {
|
||||
putenv('SYMFONY_DOTENV_PATH='.$path);
|
||||
}
|
||||
}
|
||||
}
|
||||
21
backend/vendor/symfony/dotenv/Exception/ExceptionInterface.php
vendored
Normal file
21
backend/vendor/symfony/dotenv/Exception/ExceptionInterface.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Dotenv\Exception;
|
||||
|
||||
/**
|
||||
* Interface for exceptions.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface ExceptionInterface extends \Throwable
|
||||
{
|
||||
}
|
||||
34
backend/vendor/symfony/dotenv/Exception/FormatException.php
vendored
Normal file
34
backend/vendor/symfony/dotenv/Exception/FormatException.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Dotenv\Exception;
|
||||
|
||||
/**
|
||||
* Thrown when a file has a syntax error.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
final class FormatException extends \LogicException implements ExceptionInterface
|
||||
{
|
||||
public function __construct(
|
||||
string $message,
|
||||
private FormatExceptionContext $context,
|
||||
int $code = 0,
|
||||
?\Throwable $previous = null,
|
||||
) {
|
||||
parent::__construct(\sprintf("%s in \"%s\" at line %d.\n%s", $message, $context->getPath(), $context->getLineno(), $context->getDetails()), $code, $previous);
|
||||
}
|
||||
|
||||
public function getContext(): FormatExceptionContext
|
||||
{
|
||||
return $this->context;
|
||||
}
|
||||
}
|
||||
44
backend/vendor/symfony/dotenv/Exception/FormatExceptionContext.php
vendored
Normal file
44
backend/vendor/symfony/dotenv/Exception/FormatExceptionContext.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Dotenv\Exception;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
final class FormatExceptionContext
|
||||
{
|
||||
public function __construct(
|
||||
private string $data,
|
||||
private string $path,
|
||||
private int $lineno,
|
||||
private int $cursor,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function getLineno(): int
|
||||
{
|
||||
return $this->lineno;
|
||||
}
|
||||
|
||||
public function getDetails(): string
|
||||
{
|
||||
$before = str_replace("\n", '\n', substr($this->data, max(0, $this->cursor - 20), min(20, $this->cursor)));
|
||||
$after = str_replace("\n", '\n', substr($this->data, $this->cursor, 20));
|
||||
|
||||
return '...'.$before.$after."...\n".str_repeat(' ', \strlen($before) + 2).'^ line '.$this->lineno.' offset '.$this->cursor;
|
||||
}
|
||||
}
|
||||
25
backend/vendor/symfony/dotenv/Exception/PathException.php
vendored
Normal file
25
backend/vendor/symfony/dotenv/Exception/PathException.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Dotenv\Exception;
|
||||
|
||||
/**
|
||||
* Thrown when a file does not exist or is not readable.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
final class PathException extends \RuntimeException implements ExceptionInterface
|
||||
{
|
||||
public function __construct(string $path, int $code = 0, ?\Throwable $previous = null)
|
||||
{
|
||||
parent::__construct(\sprintf('Unable to read the "%s" environment file.', $path), $code, $previous);
|
||||
}
|
||||
}
|
||||
19
backend/vendor/symfony/dotenv/LICENSE
vendored
Normal file
19
backend/vendor/symfony/dotenv/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2016-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
51
backend/vendor/symfony/dotenv/README.md
vendored
Normal file
51
backend/vendor/symfony/dotenv/README.md
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
Dotenv Component
|
||||
================
|
||||
|
||||
Symfony Dotenv parses `.env` files to make environment variables stored in them
|
||||
accessible via `$_SERVER` or `$_ENV`.
|
||||
|
||||
Getting Started
|
||||
---------------
|
||||
|
||||
```bash
|
||||
composer require symfony/dotenv
|
||||
```
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
> For an .env file with this format:
|
||||
|
||||
```env
|
||||
YOUR_VARIABLE_NAME=my-string
|
||||
```
|
||||
|
||||
```php
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
|
||||
$dotenv = new Dotenv();
|
||||
$dotenv->load(__DIR__.'/.env');
|
||||
|
||||
// you can also load several files
|
||||
$dotenv->load(__DIR__.'/.env', __DIR__.'/.env.dev');
|
||||
|
||||
// overwrites existing env variables
|
||||
$dotenv->overload(__DIR__.'/.env');
|
||||
|
||||
// loads .env, .env.local, and .env.$APP_ENV.local or .env.$APP_ENV
|
||||
$dotenv->loadEnv(__DIR__.'/.env');
|
||||
|
||||
// Usage with $_ENV
|
||||
$envVariable = $_ENV['YOUR_VARIABLE_NAME'];
|
||||
|
||||
// Usage with $_SERVER
|
||||
$envVariable = $_SERVER['YOUR_VARIABLE_NAME'];
|
||||
```
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
36
backend/vendor/symfony/dotenv/composer.json
vendored
Normal file
36
backend/vendor/symfony/dotenv/composer.json
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "symfony/dotenv",
|
||||
"type": "library",
|
||||
"description": "Registers environment variables from a .env file",
|
||||
"keywords": ["environment", "env", "dotenv"],
|
||||
"homepage": "https://symfony.com",
|
||||
"license" : "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/console": "^6.4|^7.0|^8.0",
|
||||
"symfony/process": "^6.4|^7.0|^8.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/console": "<6.4",
|
||||
"symfony/process": "<6.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\Dotenv\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
Reference in New Issue
Block a user