1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-06-27 16:36:00 +00:00

Load .env file

This commit is contained in:
Yassine Guedidi 2025-02-17 00:16:18 +01:00
parent 2db9ee2ba7
commit ad84d2b13b
6 changed files with 80 additions and 15 deletions

34
.env Normal file
View file

@ -0,0 +1,34 @@
SECRET="ch4n63m31fy0uc4n"
LOCALE=en
SERVER_NAME="Your wallabag instance"
DOMAIN_NAME=http://127.0.0.1:8000
DATABASE_URL=sqlite:///%kernel.project_dir%/data/db/wallabag.sqlite?charset=utf8
#DATABASE_URL=mysql://root:wallaroot@mariadb:3306/wallabag?charset=utf8mb4
#DATABASE_URL=postgres://wallabag:wallapass@postgres:5432/wallabag?charset=utf8
DATABASE_TABLE_PREFIX=wallabag_
FOSUSER_REGISTRATION=false
FOSUSER_CONFIRMATION=true
FOS_OAUTH_SERVER_ACCESS_TOKEN_LIFETIME=3600
FOS_OAUTH_SERVER_REFRESH_TOKEN_LIFETIME=1209600
TWOFACTOR_SENDER=no-reply@wallabag.org
MAILER_DSN=smtp://127.0.0.1
FROM_EMAIL=wallabag@example.com
RABBITMQ_HOST=rabbitmq
RABBITMQ_PORT=5672
RABBITMQ_USER=guest
RABBITMQ_PASSWORD=guest
REDIS_SCHEME=tcp
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PATH=
REDIS_PASSWORD=
RABBITMQ_PREFETCH_COUNT=10
SENTRY_DSN=

View file

@ -3,25 +3,40 @@
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug;
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
// for more information
//umask(0000);
if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
}
set_time_limit(0);
require __DIR__.'/../vendor/autoload.php';
require dirname(__DIR__).'/vendor/autoload.php';
$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev', true);
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption('--no-debug', true) && $env !== 'prod';
if ($debug) {
Debug::enable();
if (!class_exists(Application::class) || !class_exists(Dotenv::class)) {
throw new LogicException('You need to add "symfony/framework-bundle" and "symfony/dotenv" as Composer dependencies.');
}
$kernel = new AppKernel($env, $debug);
$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
}
if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
if ($_SERVER['APP_DEBUG']) {
umask(0000);
if (class_exists(Debug::class)) {
Debug::enable();
}
}
$kernel = new AppKernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);

View file

@ -19,7 +19,7 @@
<php>
<ini name="error_reporting" value="-1"/>
<server name="KERNEL_CLASS" value="AppKernel"/>
<server name="APP_ENV" value="test"/>
<server name="APP_ENV" value="test" force="true"/>
<server name="APP_DEBUG" value="0"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
</php>

View file

@ -1,10 +1,13 @@
<?php
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;
require __DIR__ . '/../vendor/autoload.php';
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
(new Filesystem())->remove(__DIR__ . '/../var/cache/test');
if (!isPartialRun()) {

View file

@ -1,10 +1,16 @@
<?php
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\HttpFoundation\Request;
require __DIR__.'/../vendor/autoload.php';
$kernel = new AppKernel('prod', false);
putenv('APP_ENV=' . $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = 'prod');
putenv('APP_DEBUG=' . $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
$kernel = new AppKernel($_SERVER['APP_ENV'], (bool )$_SERVER['APP_DEBUG']);
//$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter

View file

@ -1,5 +1,6 @@
<?php
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;
@ -19,9 +20,15 @@ if (isset($_SERVER['HTTP_CLIENT_IP'])
}
require __DIR__.'/../vendor/autoload.php';
putenv('APP_ENV=' . $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = 'dev');
putenv('APP_DEBUG=' . $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '1');
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
Debug::enable();
$kernel = new AppKernel('dev', true);
$kernel = new AppKernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();