diff --git a/.env b/.env new file mode 100644 index 000000000..48b2b1cdd --- /dev/null +++ b/.env @@ -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= diff --git a/bin/console b/bin/console index c480603e1..4220603b1 100755 --- a/bin/console +++ b/bin/console @@ -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); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a40fd7fee..4ba67d281 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,7 +19,7 @@ - + diff --git a/tests/bootstrap.php b/tests/bootstrap.php index fad77b3bb..ec499e475 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,10 +1,13 @@ bootEnv(dirname(__DIR__) . '/.env'); + (new Filesystem())->remove(__DIR__ . '/../var/cache/test'); if (!isPartialRun()) { diff --git a/web/app.php b/web/app.php index 3427e133e..71a628bfd 100644 --- a/web/app.php +++ b/web/app.php @@ -1,10 +1,16 @@ 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 diff --git a/web/app_dev.php b/web/app_dev.php index d3b01d8e8..2e7e0ed5e 100644 --- a/web/app_dev.php +++ b/web/app_dev.php @@ -1,5 +1,6 @@ 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();