From c8bee3c34f2458dae903ec2c3e14be8e3aecf1cc Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Wed, 1 Dec 2021 19:44:40 +0000 Subject: [PATCH 01/16] Updated winter install command to use ConfigFile --- modules/system/console/WinterInstall.php | 95 +++++++++++++----------- 1 file changed, 52 insertions(+), 43 deletions(-) diff --git a/modules/system/console/WinterInstall.php b/modules/system/console/WinterInstall.php index 52b8ff89bc..e412665053 100644 --- a/modules/system/console/WinterInstall.php +++ b/modules/system/console/WinterInstall.php @@ -8,7 +8,7 @@ use Config; use Backend\Database\Seeds\SeedSetupAdmin; use System\Classes\UpdateManager; -use Winter\Storm\Config\ConfigWriter; +use Winter\Storm\Config\ConfigFile; use Illuminate\Console\Command; use Illuminate\Encryption\Encrypter; use Symfony\Component\Console\Input\InputOption; @@ -38,11 +38,6 @@ class WinterInstall extends Command */ protected $description = 'Set up Winter for the first time.'; - /** - * @var Winter\Storm\Config\ConfigWriter - */ - protected $configWriter; - /** * Create a new command instance. */ @@ -50,8 +45,6 @@ public function __construct() { parent::__construct(); - $this->configWriter = new ConfigWriter; - // Register aliases for backwards compatibility with October $this->setAliases(['october:install']); } @@ -119,14 +112,15 @@ protected function getOptions() protected function setupCommonValues() { $url = $this->ask('Application URL', Config::get('app.url')); - $this->writeToConfig('app', ['url' => $url]); + $this->getConfigFile('app') + ->set('url', $url) + ->write(); } protected function setupBackendValues() { // cms.backendUri $backendUri = $this->ask('Backend URL', Config::get('cms.backendUri')); - $this->writeToConfig('cms', ['backendUri' => $backendUri]); // app.locale $defaultLocale = Config::get('app.locale'); @@ -149,7 +143,10 @@ protected function setupBackendValues() // Installation failed halfway through, recover gracefully $locale = $this->ask('Default Backend Locale', $defaultLocale); } - $this->writeToConfig('app', ['locale' => $locale]); + + $this->getConfigFile('app') + ->set('locale', $locale) + ->write(); // cms.backendTimezone $defaultTimezone = Config::get('cms.backendTimezone'); @@ -189,21 +186,32 @@ protected function setupBackendValues() // Installation failed halfway through, recover gracefully $timezone = $this->ask('Default Backend Timezone', $defaultTimezone); } - $this->writeToConfig('cms', ['backendTimezone' => $timezone]); + + $this->getConfigFile('cms') + ->set([ + 'backendTimezone' => $timezone, + 'backendUri' => $backendUri + ]) + ->write(); } protected function setupAdvancedValues() { + $defaultFileMask = $this->ask('File Permission Mask', Config::get('cms.defaultMask.file') ?: '777'); + $defaultDirMask = $this->ask('Folder Permission Mask', Config::get('cms.defaultMask.folder') ?: '777'); - - $defaultMask = $this->ask('File Permission Mask', Config::get('cms.defaultMask.file') ?: '777'); - $this->writeToConfig('cms', ['defaultMask.file' => $defaultMask]); - - $defaultMask = $this->ask('Folder Permission Mask', Config::get('cms.defaultMask.folder') ?: '777'); - $this->writeToConfig('cms', ['defaultMask.folder' => $defaultMask]); + $this->getConfigFile('cms') + ->set([ + 'defaultMask.file' => $defaultFileMask, + 'defaultMask.folder' => $defaultDirMask + ]) + ->write(); $debug = (bool) $this->confirm('Enable Debug Mode?', true); - $this->writeToConfig('app', ['debug' => $debug]); + + $this->getConfigFile('app') + ->set('debug', $debug) + ->write(); } protected function askToInstallPlugins() @@ -244,7 +252,9 @@ protected function setupEncryptionKey($force = false) } } - $this->writeToConfig('app', ['key' => $key]); + $this->getConfigFile('app') + ->set('key', $key) + ->write(); $this->info(sprintf('Application key [%s] set successfully.', $key)); } @@ -292,11 +302,15 @@ protected function setupDatabaseConfig() $newConfig = $this->$method(); - $this->writeToConfig('database', ['default' => $driver]); + $settings = ['default' => $driver]; foreach ($newConfig as $config => $value) { - $this->writeToConfig('database', ['connections.'.$driver.'.'.$config => $value]); + $settings['connections.'.$driver.'.'.$config] = $value; } + + $this->getConfigFile('database') + ->set($settings) + ->write(); } protected function setupDatabaseMysql() @@ -329,7 +343,7 @@ protected function setupDatabaseSqlite() if (!file_exists($filename)) { $directory = dirname($filename); if (!is_dir($directory)) { - mkdir($directory, 0777, true); + mkdir($directory, 0755, true); } new PDO('sqlite:'.$filename); @@ -435,30 +449,25 @@ protected function displayOutro() $this->line($message); } - protected function writeToConfig($file, $values) - { - $configFile = $this->getConfigFile($file); - - foreach ($values as $key => $value) { - Config::set($file.'.'.$key, $value); - } - - $this->configWriter->toFile($configFile, $values); - } - /** - * Get a config file and contents. + * Get a config file object. * - * @return array + * @param string $name + * @return ConfigFile */ - protected function getConfigFile($name = 'app') + protected function getConfigFile(string $name): ConfigFile { - $env = $this->option('env') ? $this->option('env').'/' : ''; - - $name .= '.php'; - - $contents = File::get($path = $this->laravel['path.config']."/{$env}{$name}"); + $file = sprintf( + '%s/%s%s.php', + $this->laravel['path.config'], + $this->option('env') ? $this->option('env') . '/' : '', + $name + ); + + if (!is_dir(dirname($file))) { + mkdir(dirname($file), 0755); + } - return $path; + return ConfigFile::read($file, true); } } From b5f2b7e1f806223113868dd999abb1bd1fee30c8 Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Thu, 2 Dec 2021 13:57:35 +0000 Subject: [PATCH 02/16] Re-implemented winter:env using EnvFile --- modules/system/console/WinterEnv.php | 336 ++++++--------------------- 1 file changed, 74 insertions(+), 262 deletions(-) diff --git a/modules/system/console/WinterEnv.php b/modules/system/console/WinterEnv.php index 42c95a7d9e..435f5cd618 100644 --- a/modules/system/console/WinterEnv.php +++ b/modules/system/console/WinterEnv.php @@ -2,6 +2,8 @@ use App; use Illuminate\Console\Command; +use Winter\Storm\Config\ConfigFile; +use Winter\Storm\Config\EnvFile; /** * Console command to convert configuration to use .env files. @@ -14,7 +16,6 @@ */ class WinterEnv extends Command { - /** * The console command name. */ @@ -47,6 +48,11 @@ class WinterEnv extends Command */ protected $connection; + /** + * @var string env file name + */ + protected $envFile = '.env'; + /** * Create a new command instance. */ @@ -60,309 +66,114 @@ public function __construct() /** * Execute the console command. + * @return int */ - public function handle() + public function handle(): int { - if (file_exists('.env')) { - return $this->error('.env file already exists.'); + if (file_exists($this->getEnvPath())) { + $this->error('.env file already exists.'); + return 1; } - $this->overwriteConfig(); + $env = EnvFile::read($this->getEnvPath()); + $this->setEnvValues($env); + $env->write(); - $this->info('.env configuration file has been created.'); - } + $this->updateConfig(); - /** - * Overwrite config file - */ - protected function overwriteConfig() - { - foreach (array_keys($this->config()) as $config) { - $this->config = $config; - $this->configToEnv(); - } - } - - /** - * Replace config values with env() syntax - */ - protected function configToEnv() - { - $content = $this->parseConfigFile(); + $this->info('.env configuration file has been created.'); - $this->writeToConfigFile($content); + return 0; } /** - * Parse config file line by line - * + * Get the full path of the env file * @return string */ - protected function parseConfigFile() - { - $lines = []; - - foreach ($this->lines() as $line) { - $keys = $this->config()[$this->config]; - - $lines[] = $this->parseLine($line, $keys); - } - - $this->writeToEnv("\n"); - - return implode('', $lines); - } - - /** - * @param $keys - * @param $line - * @return mixed - */ - protected function parseLine($line, $keys) - { - $line = $this->replaceConfigLine($line, $keys); - - $line = $this->replaceDbConfigLine($line); - - return $line; - } - - /** - * @param $line - * @param $keys - * @return mixed - */ - protected function replaceConfigLine($line, $keys) + protected function getEnvPath(): string { - foreach ($keys as $envKey => $configKey) { - $pattern = $this->buildPattern($configKey); - - $callback = $this->buildCallback($envKey, $configKey); - - if (preg_match($pattern, $line)) { - $line = preg_replace_callback($pattern, $callback, $line); - } - } - - return $line; + return base_path($this->envFile); } /** - * @param $line - * @return mixed - */ - protected function replaceDbConfigLine($line) - { - if ($this->config == 'database') { - foreach ($this->dbConfig() as $connection => $settings) { - $this->setCurrentConnection($line, $connection); - - if ($this->connection == $connection) { - $line = $this->replaceConfigLine($line, $settings); - } - } - } - - return $line; - } - - /** - * @param $line - * @param $connection - */ - protected function setCurrentConnection($line, $connection) - { - if (preg_match("/['\"]" . $connection . "['\"]" . "\s*=>/", $line)) { - $this->connection = $connection; - } - } - - /** - * @param $configKey + * Get the full path of a config file + * @param string $config * @return string */ - protected function buildPattern($configKey) - { - return "/['\"]" . $configKey . "['\"]" . "\s*=>\s*[^,\[]+,/"; - } - - /** - * @param $envKey - * @param $configKey - * @return \Closure - */ - protected function buildCallback($envKey, $configKey) + protected function getConfigPath(string $config): string { - return function ($matches) use ($envKey, $configKey) { - $value = $this->envValue($configKey); - - $this->saveEnvSettings($envKey, $this->normalizeForEnv($value)); - - // Remove protected values from the config files - if (in_array($envKey, $this->protectedKeys) && !empty($value)) { - $value = ''; - } - - return $this->isEnv($matches[0]) ? $matches[0] : "'$configKey' => env('$envKey', {$this->normalizeForConfig($value)}),"; - }; + return rtrim(App::make('path.config'), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $config . '.php'; } /** - * @param $key - * @param $value + * Set env keys to their config values within the EnvFile object + * @param EnvFile $env + * @return void */ - protected function saveEnvSettings($key, $value) + protected function setEnvValues(EnvFile $env): void { - if (! $this->envKeyExists($key)) { - $line = sprintf("%s=%s\n", $key, $value); - - if ($this->config == 'database' && $key != 'DB_CONNECTION') { - $this->writeDbEnvSettings($line); - } else { - $this->writeToEnv($line); + foreach ($this->config() as $config => $items) { + foreach ($items as $envKey => $configKey) { + $env->set($envKey, config($config . '.' . $configKey)); + if ($config === 'database' && $envKey === 'DB_CONNECTION') { + if (!$databaseConfig = $this->dbConfig()[config($config . '.' . $configKey)] ?? null) { + continue; + } + foreach ($databaseConfig as $dbEnvKey => $dbConfigKey) { + $env->set($dbEnvKey, config($config . '.' . $dbConfigKey)); + } + } } + $env->addNewLine(); } } /** - * @param $line - */ - protected function writeDbEnvSettings($line) - { - if ($this->connection == config('database.default') || $this->connection == 'redis') { - $this->writeToEnv($line); - } - } - - /** - * @param $configKey - * @return string - */ - protected function envValue($configKey) - { - $value = config("$this->config.$configKey"); - - if ($this->config == 'database') { - $value = $this->databaseConfigValue($configKey); - } - - return $value; - } - - /** - * @param $configKey - * @return string - */ - protected function databaseConfigValue($configKey) - { - if ($configKey == 'default') { - return config('database.default'); - } - - if ($configKey == 'useConfigForTesting') { - return config('database.useConfigForTesting'); - } - - if ($this->connection == 'redis') { - return config("database.redis.default.$configKey"); - } - - return config("database.connections.$this->connection.$configKey"); - } - - /** - * Normalizes a value to be inserted into the .env file - * - * @param $value - * @return string - */ - protected function normalizeForEnv($value) - { - if (is_string($value)) { - if (preg_match('/["\'#]/', $value)) { - return '"' . str_replace('"', '\\"', $value) . '"'; - } else { - return $value; + * Update config files with env function calls + * @return void + */ + protected function updateConfig(): void + { + foreach ($this->config() as $config => $items) { + $conf = ConfigFile::read($this->getConfigPath($config)); + foreach ($items as $envKey => $configKey) { + $conf->set( + $configKey, + $conf->function('env', $this->getEnvArgs($envKey, $config . '.' . $configKey)) + ); + if ($config === 'database' && $envKey === 'DB_CONNECTION') { + foreach ($this->dbConfig() as $connection => $keys) { + foreach ($keys as $dbEnvKey => $dbConfigKey) { + $path = sprintf('connections.%s.%s', $connection, $dbConfigKey); + $conf->set( + $path, + $conf->function('env', $this->getEnvArgs($dbEnvKey, $config . '.' . $path)) + ); + } + } + } } - } elseif (is_bool($value)) { - return $value ? 'true' : 'false'; - } elseif ($value === null) { - return 'null'; + $conf->write(); } - - return $value; - } - - /** - * Normalizes a value to be inserted into config files. - * - * @param $value - * @return string - */ - protected function normalizeForConfig($value) - { - if (is_string($value)) { - return '\'' . addslashes($value) . '\''; - } - - return $this->normalizeForEnv($value); - } - - /** - * @param $matches - * @return bool - */ - protected function isEnv($matches) - { - return strpos($matches, 'env') !== false; - } - - /** - * @param $content - */ - protected function writeToEnv($content) - { - file_put_contents('.env', $content, FILE_APPEND); - } - - /** - * @return string - */ - protected function readEnvFile() - { - return file_exists('.env') ? file_get_contents('.env') : ''; - } - - /** - * @param $content - */ - protected function writeToConfigFile($content) - { - file_put_contents(rtrim(App::make('path.config'), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $this->config . '.php', $content); } /** + * Return an array used to generate the arguments for an env function call with protection of specific keys + * @param string $envConfig + * @param string $path * @return array */ - protected function lines() - { - return file(rtrim(App::make('path.config'), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $this->config . '.php'); - } - - /** - * @param $key - * @return bool - */ - protected function envKeyExists($key) + protected function getEnvArgs(string $envConfig, string $path): array { - return strpos($this->readEnvFile(), $key) !== false; + return [$envConfig, in_array($envConfig, $this->protectedKeys) ? '' : config($path)]; } /** + * Returns a map of env keys to php config keys for db configs * @return array */ - protected function config() + protected function config(): array { return [ 'app' => [ @@ -402,9 +213,10 @@ protected function config() } /** + * Returns a map of env keys to php config keys for db configs * @return array */ - protected function dbConfig() + protected function dbConfig(): array { return [ 'sqlite' => [ From b0cff6b624d2a0f72d94564a1e82e248981100ea Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Fri, 14 Jan 2022 02:50:15 +0000 Subject: [PATCH 03/16] Added fix to when loading config values to write in env file --- modules/system/console/WinterEnv.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/system/console/WinterEnv.php b/modules/system/console/WinterEnv.php index 435f5cd618..90bd4bfc90 100644 --- a/modules/system/console/WinterEnv.php +++ b/modules/system/console/WinterEnv.php @@ -117,11 +117,11 @@ protected function setEnvValues(EnvFile $env): void foreach ($items as $envKey => $configKey) { $env->set($envKey, config($config . '.' . $configKey)); if ($config === 'database' && $envKey === 'DB_CONNECTION') { - if (!$databaseConfig = $this->dbConfig()[config($config . '.' . $configKey)] ?? null) { - continue; - } - foreach ($databaseConfig as $dbEnvKey => $dbConfigKey) { - $env->set($dbEnvKey, config($config . '.' . $dbConfigKey)); + $default = config('database.default'); + $dbConfig = $this->dbConfig()[$default] ?? []; + + foreach ($dbConfig as $dbEnvKey => $dbConfigKey) { + $env->set($dbEnvKey, config(join('.', [$config, 'connections', $default, $dbConfigKey]))); } } } From 7b6244d86e8f1dd847323265ec5433bfcc1661ee Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Fri, 14 Jan 2022 02:50:59 +0000 Subject: [PATCH 04/16] Updated test case with all strings being quoted --- tests/unit/system/console/WinterEnvTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/system/console/WinterEnvTest.php b/tests/unit/system/console/WinterEnvTest.php index 2ef64d2770..6fe855bcb9 100644 --- a/tests/unit/system/console/WinterEnvTest.php +++ b/tests/unit/system/console/WinterEnvTest.php @@ -31,8 +31,8 @@ public function testCommand() $envFile = file_get_contents(base_path('.env')); $this->assertStringContainsString('APP_DEBUG=true', $envFile); - $this->assertStringContainsString('APP_URL=https://localhost', $envFile); - $this->assertStringContainsString('DB_CONNECTION=mysql', $envFile); + $this->assertStringContainsString('APP_URL="https://localhost"', $envFile); + $this->assertStringContainsString('DB_CONNECTION="mysql"', $envFile); $this->assertStringContainsString('DB_DATABASE="data#base"', $envFile); $this->assertStringContainsString('DB_USERNAME="teal\'c"', $envFile); $this->assertStringContainsString('DB_PASSWORD="test\\"quotes\'test"', $envFile); From 897263e2813596e116ed0b1350e1a9034a646cb0 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Thu, 17 Feb 2022 10:46:22 -0600 Subject: [PATCH 05/16] Run default config files through ConfigWriter to minimize changed lines on future uses --- config/app.php | 74 +++++++++---------- config/auth.php | 56 ++++++++------- config/broadcasting.php | 35 ++++----- config/cache.php | 64 +++++++---------- config/cms.php | 152 ++++++++++++++++++++-------------------- config/cookie.php | 9 +-- config/database.php | 119 ++++++++++++++----------------- config/develop.php | 9 ++- config/environment.php | 11 ++- config/filesystems.php | 30 ++++---- config/hashing.php | 17 +++-- config/logging.php | 72 +++++++++---------- config/mail.php | 40 +++++------ config/queue.php | 65 ++++++++--------- config/services.php | 13 ++-- config/session.php | 68 +++++++++--------- config/view.php | 20 ++---- 17 files changed, 385 insertions(+), 469 deletions(-) diff --git a/config/app.php b/config/app.php index 4ba2ad7f91..813e09110e 100644 --- a/config/app.php +++ b/config/app.php @@ -1,7 +1,7 @@ env('APP_DEBUG', true), - + /* |-------------------------------------------------------------------------- | Application Name @@ -28,9 +28,9 @@ | any other location as required by the application or its packages. | */ - + 'name' => env('APP_NAME', 'Winter CMS'), - + /* |-------------------------------------------------------------------------- | Application URL @@ -41,9 +41,9 @@ | your application so that it is used when running Artisan tasks. | */ - + 'url' => env('APP_URL', 'http://localhost'), - + /* |-------------------------------------------------------------------------- | Asset URL @@ -57,9 +57,9 @@ | 'asset_url' => 'https://cdn.example.com/', | */ - + 'asset_url' => env('ASSET_URL', null), - + /* |-------------------------------------------------------------------------- | Trusted hosts @@ -87,9 +87,9 @@ | NOTE: Even when set to `false`, this functionality is explicitly enabled | on the Backend password reset flow for security reasons. */ - + 'trustedHosts' => false, - + /* |-------------------------------------------------------------------------- | Trusted proxies @@ -115,9 +115,9 @@ | 'trustedProxies' => '192.168.1.1, 192.168.1.2' | 'trustedProxies' => ['192.168.1.1', '192.168.1.2'] */ - + 'trustedProxies' => null, - + /* |-------------------------------------------------------------------------- | Trusted proxy headers @@ -150,9 +150,9 @@ | | - Amazon ELB users should always use the "HEADER_X_FORWARDED_AWS_ELB" option. */ - + 'trustedProxyHeaders' => 'HEADER_X_FORWARDED_ALL', - + /* |-------------------------------------------------------------------------- | Application Timezone @@ -171,9 +171,9 @@ | to display dates & times. | */ - + 'timezone' => 'UTC', - + /* |-------------------------------------------------------------------------- | Application Locale Configuration @@ -190,9 +190,9 @@ | Backend\Models\Preference->getLocaleOptions() | */ - + 'locale' => 'en', - + /* |-------------------------------------------------------------------------- | Application Fallback Locale @@ -203,9 +203,9 @@ | the language folders that are provided through your application. | */ - + 'fallback_locale' => 'en', - + /* |-------------------------------------------------------------------------- | Faker Locale @@ -216,9 +216,9 @@ | localized telephone numbers, street address information and more. | */ - + 'faker_locale' => 'en_US', - + /* |-------------------------------------------------------------------------- | Encryption Key @@ -229,11 +229,10 @@ | will not be safe. Please do this before deploying an application! | */ - + 'key' => env('APP_KEY'), - 'cipher' => 'AES-256-CBC', - + /* |-------------------------------------------------------------------------- | Autoloaded Service Providers @@ -244,14 +243,12 @@ | this array to grant expanded functionality to your applications. | */ - - 'providers' => array_merge(include(base_path('modules/system/providers.php')), [ - + + 'providers' => array_merge(include base_path('modules/system/providers.php'), [ // 'Illuminate\Html\HtmlServiceProvider', // Example - - 'System\ServiceProvider', + 'System\\ServiceProvider', ]), - + /* |-------------------------------------------------------------------------- | Load automatically discovered packages @@ -269,9 +266,9 @@ | even if discovery is disabled. | */ - + 'loadDiscoveredPackages' => false, - + /* |-------------------------------------------------------------------------- | Class Aliases @@ -282,11 +279,6 @@ | the aliases are "lazy" loaded so they don't hinder performance. | */ - - 'aliases' => array_merge(include(base_path('modules/system/aliases.php')), [ - - // 'Str' => 'Illuminate\Support\Str', // Example - - ]), - + + 'aliases' => array_merge(include base_path('modules/system/aliases.php'), []), ]; diff --git a/config/auth.php b/config/auth.php index 8dc13b61c7..2acc88e6b4 100644 --- a/config/auth.php +++ b/config/auth.php @@ -1,39 +1,41 @@ [ + /* - |-------------------------------------------------------------------------- - | Enable throttling of Backend authentication attempts - |-------------------------------------------------------------------------- - | - | If set to true, users will be given a limited number of attempts to sign - | in to the Backend before being blocked for a specified number of minutes. - | - */ + |-------------------------------------------------------------------------- + | Enable throttling of Backend authentication attempts + |-------------------------------------------------------------------------- + | + | If set to true, users will be given a limited number of attempts to sign + | in to the Backend before being blocked for a specified number of minutes. + | + */ + 'enabled' => true, - + /* - |-------------------------------------------------------------------------- - | Failed Authentication Attempt Limit - |-------------------------------------------------------------------------- - | - | Number of failed attempts allowed while trying to authenticate a user. - | - */ + |-------------------------------------------------------------------------- + | Failed Authentication Attempt Limit + |-------------------------------------------------------------------------- + | + | Number of failed attempts allowed while trying to authenticate a user. + | + */ + 'attemptLimit' => 5, - + /* - |-------------------------------------------------------------------------- - | Suspension Time - |-------------------------------------------------------------------------- - | - | The number of minutes to suspend further attempts on authentication once - | the attempt limit is reached. - | - */ + |-------------------------------------------------------------------------- + | Suspension Time + |-------------------------------------------------------------------------- + | + | The number of minutes to suspend further attempts on authentication once + | the attempt limit is reached. + | + */ + 'suspensionTime' => 15, ], - ]; diff --git a/config/broadcasting.php b/config/broadcasting.php index 542f5f1de3..4210685ba4 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -1,7 +1,7 @@ env('BROADCAST_DRIVER', 'null'), - + /* |-------------------------------------------------------------------------- | Broadcast Connections @@ -27,41 +27,32 @@ | each available type of connection are provided inside this array. | */ - + 'connections' => [ - 'pusher' => [ - 'app_id' => env('PUSHER_APP_ID'), - 'client_options' => [ - // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html - ], - 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY'), - 'options' => [ + 'app_id' => env('PUSHER_APP_ID'), + 'client_options' => [], + 'driver' => 'pusher', + 'key' => env('PUSHER_APP_KEY'), + 'options' => [ 'cluster' => env('PUSHER_APP_CLUSTER'), - 'useTLS' => true, + 'useTLS' => true, ], - 'secret' => env('PUSHER_APP_SECRET'), + 'secret' => env('PUSHER_APP_SECRET'), ], - 'ably' => [ 'driver' => 'ably', - 'key' => env('ABLY_KEY'), + 'key' => env('ABLY_KEY'), ], - 'redis' => [ 'connection' => 'default', - 'driver' => 'redis', + 'driver' => 'redis', ], - 'log' => [ 'driver' => 'log', ], - 'null' => [ 'driver' => 'null', ], - ], - ]; diff --git a/config/cache.php b/config/cache.php index e2bba31603..22597b4cd3 100644 --- a/config/cache.php +++ b/config/cache.php @@ -1,7 +1,7 @@ env('CACHE_DRIVER', 'file'), - + /* |-------------------------------------------------------------------------- | Cache Stores @@ -33,41 +33,34 @@ | "memcached", "redis", "dynamodb", "octane", "null" | */ - + 'stores' => [ - 'apc' => [ 'driver' => 'apc', ], - 'array' => [ - 'driver' => 'array', + 'driver' => 'array', 'serialize' => false, ], - 'database' => [ - 'connection' => null, - 'driver' => 'database', + 'connection' => null, + 'driver' => 'database', 'lock_connection' => null, - 'table' => 'cache', + 'table' => 'cache', ], - 'file' => [ 'driver' => 'file', - 'path' => storage_path('framework/cache'), + 'path' => storage_path('framework/cache'), ], - 'memcached' => [ - 'driver' => 'memcached', - 'options' => [ - // Memcached::OPT_CONNECT_TIMEOUT => 2000, - ], + 'driver' => 'memcached', + 'options' => [], 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 'sasl' => [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], - 'servers' => [ + 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 'port' => env('MEMCACHED_PORT', 11211), @@ -75,28 +68,24 @@ ], ], ], - 'redis' => [ - 'connection' => 'cache', - 'driver' => 'redis', + 'connection' => 'cache', + 'driver' => 'redis', 'lock_connection' => 'default', ], - 'dynamodb' => [ - 'driver' => 'dynamodb', + 'driver' => 'dynamodb', 'endpoint' => env('DYNAMODB_ENDPOINT'), - 'key' => env('AWS_ACCESS_KEY_ID'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), ], - 'octane' => [ 'driver' => 'octane', ], - ], - + /* |-------------------------------------------------------------------------- | Cache Key Prefix @@ -107,9 +96,9 @@ | value to get prefixed to all our keys so we can avoid collisions. | */ - - 'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'winter'), '_').'_cache'), - + + 'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'winter'), '_') . '_cache'), + /* |-------------------------------------------------------------------------- | Cache Key for the CMS' PHP code parser cache @@ -121,9 +110,9 @@ | prevent conflicts. | */ - + 'codeParserDataCacheKey' => 'cms-php-file-data', - + /* |-------------------------------------------------------------------------- | Disable Request Cache @@ -143,7 +132,6 @@ | null - enable for HTTP requests, disable when running in CLI | */ - + 'disableRequestCache' => null, - ]; diff --git a/config/cms.php b/config/cms.php index 4da7fd4a7e..483d13fdfa 100644 --- a/config/cms.php +++ b/config/cms.php @@ -1,7 +1,7 @@ 'demo', - + /* |-------------------------------------------------------------------------- | Bleeding edge updates @@ -23,9 +23,9 @@ | and use the development copies of core files and plugins. | */ - + 'edgeUpdates' => false, - + /* |-------------------------------------------------------------------------- | Back-end URI prefix @@ -35,9 +35,9 @@ | For example: backend -> http://localhost/backend | */ - + 'backendUri' => 'backend', - + /* |-------------------------------------------------------------------------- | Back-end force HTTPS security @@ -48,9 +48,9 @@ | web server config, but can be handled by the app for added security. | */ - + 'backendForceSecure' => false, - + /* |-------------------------------------------------------------------------- | Back-end login remember @@ -66,9 +66,9 @@ | wanted behavior | */ - + 'backendForceRemember' => true, - + /* |-------------------------------------------------------------------------- | Back-end timezone @@ -79,9 +79,9 @@ | dates displayed in the back-end will be converted to this timezone. | */ - + 'backendTimezone' => 'UTC', - + /* |-------------------------------------------------------------------------- | Back-end Skin @@ -90,9 +90,9 @@ | Specifies the back-end skin to use. | */ - - 'backendSkin' => 'Backend\Skins\Standard', - + + 'backendSkin' => 'Backend\\Skins\\Standard', + /* |-------------------------------------------------------------------------- | Automatically run migrations on login @@ -105,9 +105,9 @@ | and disabled when debug mode is disabled. | */ - + 'runMigrationsOnLogin' => null, - + /* |-------------------------------------------------------------------------- | Determines which modules to load @@ -116,9 +116,13 @@ | Specify which modules should be registered when using the application. | */ - - 'loadModules' => ['System', 'Backend', 'Cms'], - + + 'loadModules' => [ + 'System', + 'Backend', + 'Cms', + ], + /* |-------------------------------------------------------------------------- | Prevents application updates @@ -130,9 +134,9 @@ | and themes will still be downloaded. | */ - + 'disableCoreUpdates' => false, - + /* |-------------------------------------------------------------------------- | Specific plugins to disable @@ -141,9 +145,9 @@ | Specify plugin codes which will always be disabled in the application. | */ - + 'disablePlugins' => [], - + /* |-------------------------------------------------------------------------- | Determines if the routing caching is enabled. @@ -155,9 +159,9 @@ | to disable the caching during the development, and enable it in the production mode. | */ - + 'enableRoutesCache' => false, - + /* |-------------------------------------------------------------------------- | Time to live for the URL map. @@ -168,9 +172,9 @@ | interval, in minutes, specified with the urlMapCacheTTL parameter expires. | */ - + 'urlCacheTtl' => 10, - + /* |-------------------------------------------------------------------------- | Time to live for parsed CMS objects. @@ -181,9 +185,9 @@ | the corresponding template file is modified. | */ - + 'parsedPageCacheTTL' => 10, - + /* |-------------------------------------------------------------------------- | Determines if the asset caching is enabled. @@ -195,9 +199,9 @@ | to disable the caching during the development, and enable it in the production mode. | */ - + 'enableAssetCache' => false, - + /* |-------------------------------------------------------------------------- | Determines if the asset minification is enabled. @@ -209,9 +213,9 @@ | when debug mode (app.debug) is disabled. | */ - + 'enableAssetMinify' => null, - + /* |-------------------------------------------------------------------------- | Check import timestamps when combining assets @@ -223,9 +227,9 @@ | is used when debug mode (app.debug) is enabled. | */ - + 'enableAssetDeepHashing' => null, - + /* |-------------------------------------------------------------------------- | Database-driven Themes @@ -249,9 +253,9 @@ | from the database. | */ - + 'databaseTemplates' => false, - + /* |-------------------------------------------------------------------------- | Public plugins path @@ -261,9 +265,9 @@ | or you can specify a full URL path. | */ - + 'pluginsPath' => '/plugins', - + /* |-------------------------------------------------------------------------- | Public themes path @@ -273,9 +277,9 @@ | or you can specify a full URL path. | */ - + 'themesPath' => '/themes', - + /* |-------------------------------------------------------------------------- | Resource storage @@ -310,30 +314,26 @@ | path for the uploads disk and `/projects/winter/storage/app/media` as | the path for the media disk. */ - + 'storage' => [ - 'uploads' => [ - 'disk' => 'local', - 'folder' => 'uploads', - 'path' => '/storage/app/uploads', + 'disk' => 'local', + 'folder' => 'uploads', + 'path' => '/storage/app/uploads', 'temporaryUrlTTL' => 3600, ], - 'media' => [ - 'disk' => 'local', + 'disk' => 'local', 'folder' => 'media', - 'path' => '/storage/app/media', + 'path' => '/storage/app/media', ], - 'resized' => [ - 'disk' => 'local', + 'disk' => 'local', 'folder' => 'resized', - 'path' => '/storage/app/resized', + 'path' => '/storage/app/resized', ], - ], - + /* |-------------------------------------------------------------------------- | Convert Line Endings @@ -343,9 +343,9 @@ | \r\n to the unix style \n. | */ - + 'convertLineEndings' => false, - + /* |-------------------------------------------------------------------------- | Linking policy @@ -359,9 +359,9 @@ | force - force hostname and schema using app.url config value | */ - + 'linkPolicy' => 'detect', - + /* |-------------------------------------------------------------------------- | Default permission mask @@ -370,9 +370,12 @@ | Specifies a default file and folder permission for newly created objects. | */ - - 'defaultMask' => ['file' => null, 'folder' => null], - + + 'defaultMask' => [ + 'file' => null, + 'folder' => null, + ], + /* |-------------------------------------------------------------------------- | Safe mode @@ -383,9 +386,9 @@ | debug mode (app.debug) is disabled. | */ - + 'enableSafeMode' => null, - + /* |-------------------------------------------------------------------------- | Cross Site Request Forgery (CSRF) Protection @@ -395,9 +398,9 @@ | checked for a valid security token. | */ - + 'enableCsrfProtection' => true, - + /* |-------------------------------------------------------------------------- | Force bytecode invalidation @@ -408,9 +411,9 @@ | cache won't update the cache, set to true to get around this. | */ - + 'forceBytecodeInvalidation' => true, - + /* |-------------------------------------------------------------------------- | Twig Strict Variables @@ -423,9 +426,9 @@ | enabled. | */ - + 'enableTwigStrictVariables' => false, - + /* |-------------------------------------------------------------------------- | Base Directory Restriction @@ -442,9 +445,9 @@ | NEVER have this disabled in production. | */ - + 'restrictBaseDir' => true, - + /* |-------------------------------------------------------------------------- | Backend Service Worker @@ -464,7 +467,6 @@ | false - disallow service workers to run in the backend | */ - + 'enableBackendServiceWorkers' => false, - ]; diff --git a/config/cookie.php b/config/cookie.php index f286fe5a6b..a6c8528d76 100644 --- a/config/cookie.php +++ b/config/cookie.php @@ -1,7 +1,7 @@ [ - // 'my_cookie', - ], - + + 'unencryptedCookies' => [], ]; diff --git a/config/database.php b/config/database.php index 2d612ab1ce..5d4bd6c398 100644 --- a/config/database.php +++ b/config/database.php @@ -1,7 +1,7 @@ env('DB_CONNECTION', 'mysql'), - + /* |-------------------------------------------------------------------------- | Database Connections @@ -29,68 +29,63 @@ | choice installed on your machine before you begin development. | */ - + 'connections' => [ - 'sqlite' => [ - 'database' => env('DB_DATABASE', storage_path('database.sqlite')), - 'driver' => 'sqlite', + 'database' => env('DB_DATABASE', storage_path('database.sqlite')), + 'driver' => 'sqlite', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), - 'prefix' => '', - 'url' => env('DATABASE_URL'), + 'prefix' => '', + 'url' => env('DATABASE_URL'), ], - 'mysql' => [ - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'mysql', - 'engine' => 'InnoDB', - 'host' => env('DB_HOST', '127.0.0.1'), - 'options' => extension_loaded('pdo_mysql') ? array_filter([ + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'mysql', + 'engine' => 'InnoDB', + 'host' => env('DB_HOST', '127.0.0.1'), + 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '3306'), - 'prefix' => '', + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '3306'), + 'prefix' => '', 'prefix_indexes' => true, - 'strict' => true, - 'unix_socket' => env('DB_SOCKET', ''), - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), - 'varcharmax' => 191, + 'strict' => true, + 'unix_socket' => env('DB_SOCKET', ''), + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), + 'varcharmax' => 191, ], - 'pgsql' => [ - 'charset' => 'utf8', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'pgsql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '5432'), - 'prefix' => '', + 'charset' => 'utf8', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'pgsql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '5432'), + 'prefix' => '', 'prefix_indexes' => true, - 'search_path' => 'public', - 'sslmode' => 'prefer', - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), + 'search_path' => 'public', + 'sslmode' => 'prefer', + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), ], - 'sqlsrv' => [ - 'charset' => 'utf8', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'sqlsrv', - 'host' => env('DB_HOST', '127.0.0.1'), - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '1433'), - 'prefix' => '', + 'charset' => 'utf8', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'sqlsrv', + 'host' => env('DB_HOST', '127.0.0.1'), + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '1433'), + 'prefix' => '', 'prefix_indexes' => true, - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), ], - ], - + /* |-------------------------------------------------------------------------- | Migration Repository Table @@ -101,9 +96,9 @@ | the migrations on disk haven't actually been run in the database. | */ - + 'migrations' => 'migrations', - + /* |-------------------------------------------------------------------------- | Redis Databases @@ -114,32 +109,26 @@ | such as APC or Memcached. Winter makes it easy to dig right in. | */ - + 'redis' => [ - 'client' => env('REDIS_CLIENT', 'phpredis'), - 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', str_slug(env('APP_NAME', 'winter'), '_').'_database_'), + 'prefix' => env('REDIS_PREFIX', str_slug(env('APP_NAME', 'winter'), '_') . '_database_'), ], - 'default' => [ 'database' => env('REDIS_DB', '0'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'url' => env('REDIS_URL'), + 'port' => env('REDIS_PORT', '6379'), + 'url' => env('REDIS_URL'), ], - 'cache' => [ 'database' => env('REDIS_CACHE_DB', '1'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'url' => env('REDIS_URL'), + 'port' => env('REDIS_PORT', '6379'), + 'url' => env('REDIS_URL'), ], - ], - ]; diff --git a/config/develop.php b/config/develop.php index 381b56409d..47c89175c8 100644 --- a/config/develop.php +++ b/config/develop.php @@ -1,7 +1,7 @@ false, - + /* |-------------------------------------------------------------------------- | Allow deep-level symlinks @@ -40,7 +40,6 @@ | false - only allow symlinks at the first level of subdirectories (default) | */ - + 'allowDeepSymlinks' => false, - ]; diff --git a/config/environment.php b/config/environment.php index 5249b15bad..fb17f634df 100644 --- a/config/environment.php +++ b/config/environment.php @@ -1,7 +1,7 @@ 'development', - + /* |-------------------------------------------------------------------------- | Environment Multitenancy @@ -25,11 +25,8 @@ | different configuration, such as database and theme, per hostname. | */ - + 'hosts' => [ - 'localhost' => 'dev', - ], - ]; diff --git a/config/filesystems.php b/config/filesystems.php index a85fcc8a9e..0fc1103700 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -1,7 +1,7 @@ env('FILESYSTEM_DISK', 'local'), - + /* |-------------------------------------------------------------------------- | Filesystem Disks @@ -27,26 +27,22 @@ | Supported Drivers: "local", "ftp", "sftp", "s3" | */ - + 'disks' => [ - 'local' => [ 'driver' => 'local', - 'root' => storage_path('app'), - 'url' => '/storage/app', + 'root' => storage_path('app'), + 'url' => '/storage/app', ], - 's3' => [ - 'bucket' => env('AWS_BUCKET'), - 'driver' => 's3', - 'endpoint' => env('AWS_ENDPOINT'), - 'key' => env('AWS_ACCESS_KEY_ID'), - 'region' => env('AWS_DEFAULT_REGION'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'url' => env('AWS_URL'), + 'bucket' => env('AWS_BUCKET'), + 'driver' => 's3', + 'endpoint' => env('AWS_ENDPOINT'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'region' => env('AWS_DEFAULT_REGION'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'url' => env('AWS_URL'), 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), ], - ], - ]; diff --git a/config/hashing.php b/config/hashing.php index 616059443b..f8c867896a 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -1,7 +1,7 @@ 'bcrypt', - + /* |-------------------------------------------------------------------------- | Bcrypt Options @@ -27,11 +27,11 @@ | to control the amount of time it takes to hash the given password. | */ - + 'bcrypt' => [ 'rounds' => env('BCRYPT_ROUNDS', 10), ], - + /* |-------------------------------------------------------------------------- | Argon Options @@ -42,11 +42,10 @@ | to control the amount of time it takes to hash the given password. | */ - + 'argon' => [ - 'memory' => 65536, + 'memory' => 65536, 'threads' => 1, - 'time' => 4, + 'time' => 4, ], - ]; diff --git a/config/logging.php b/config/logging.php index e7ea8f3bb6..e60a3fa51f 100644 --- a/config/logging.php +++ b/config/logging.php @@ -1,7 +1,7 @@ env('LOG_CHANNEL', 'stack'), - + /* |-------------------------------------------------------------------------- | Deprecations Log Channel @@ -25,9 +25,9 @@ | your application ready for upcoming major versions of dependencies. | */ - + 'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), - + /* |-------------------------------------------------------------------------- | Log Channels @@ -42,74 +42,66 @@ | "custom", "stack" | */ - + 'channels' => [ 'stack' => [ - 'channels' => ['single'], - 'driver' => 'stack', + 'channels' => [ + 'single', + ], + 'driver' => 'stack', 'ignore_exceptions' => false, ], - 'single' => [ 'driver' => 'single', - 'level' => env('LOG_LEVEL', 'debug'), - 'path' => storage_path('logs/system.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'path' => storage_path('logs/system.log'), ], - 'daily' => [ - 'days' => 14, + 'days' => 14, 'driver' => 'daily', - 'level' => env('LOG_LEVEL', 'debug'), - 'path' => storage_path('logs/system.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'path' => storage_path('logs/system.log'), ], - 'slack' => [ - 'driver' => 'slack', - 'emoji' => ':boom:', - 'level' => env('LOG_LEVEL', 'critical'), - 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'driver' => 'slack', + 'emoji' => ':boom:', + 'level' => env('LOG_LEVEL', 'critical'), + 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Winter Log', ], - 'papertrail' => [ - 'driver' => 'monolog', - 'handler' => env('LOG_PAPERTRAIL_HANDLER', \Monolog\Handler\SyslogUdpHandler::class), + 'driver' => 'monolog', + 'handler' => env('LOG_PAPERTRAIL_HANDLER', \Monolog\Handler\SyslogUdpHandler::class), 'handler_with' => [ - 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), - 'host' => env('PAPERTRAIL_URL'), - 'port' => env('PAPERTRAIL_PORT'), + 'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'), + 'host' => env('PAPERTRAIL_URL'), + 'port' => env('PAPERTRAIL_PORT'), ], - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], - 'stderr' => [ - 'driver' => 'monolog', + 'driver' => 'monolog', 'formatter' => env('LOG_STDERR_FORMATTER'), - 'handler' => \Monolog\Handler\StreamHandler::class, - 'level' => env('LOG_LEVEL', 'debug'), - 'with' => [ + 'handler' => \Monolog\Handler\StreamHandler::class, + 'level' => env('LOG_LEVEL', 'debug'), + 'with' => [ 'stream' => 'php://stderr', ], ], - 'syslog' => [ 'driver' => 'syslog', - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], - 'errorlog' => [ 'driver' => 'errorlog', - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], - 'null' => [ - 'driver' => 'monolog', + 'driver' => 'monolog', 'handler' => \Monolog\Handler\NullHandler::class, ], - 'emergency' => [ 'path' => storage_path('logs/system.log'), ], ], - ]; diff --git a/config/mail.php b/config/mail.php index 25a896d141..d1c10db337 100644 --- a/config/mail.php +++ b/config/mail.php @@ -1,7 +1,7 @@ env('MAIL_MAILER', 'smtp'), - + /* |-------------------------------------------------------------------------- | Mailer Configurations @@ -32,53 +32,46 @@ | "postmark", "log", "array", "failover" | */ - + 'mailers' => [ 'smtp' => [ 'encryption' => env('MAIL_ENCRYPTION', 'tls'), - 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), - 'password' => env('MAIL_PASSWORD'), - 'port' => env('MAIL_PORT', 587), - 'timeout' => null, - 'transport' => 'smtp', - 'username' => env('MAIL_USERNAME'), + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), + 'password' => env('MAIL_PASSWORD'), + 'port' => env('MAIL_PORT', 587), + 'timeout' => null, + 'transport' => 'smtp', + 'username' => env('MAIL_USERNAME'), ], - 'ses' => [ 'transport' => 'ses', ], - 'mailgun' => [ 'transport' => 'mailgun', ], - 'postmark' => [ 'transport' => 'postmark', ], - 'sendmail' => [ - 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), + 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), 'transport' => 'sendmail', ], - 'log' => [ - 'channel' => env('MAIL_LOG_CHANNEL'), + 'channel' => env('MAIL_LOG_CHANNEL'), 'transport' => 'log', ], - 'array' => [ 'transport' => 'array', ], - 'failover' => [ - 'mailers' => [ + 'mailers' => [ 'smtp', 'log', ], 'transport' => 'failover', ], ], - + /* |-------------------------------------------------------------------------- | Global "From" Address @@ -89,10 +82,9 @@ | used globally for all e-mails that are sent by your application. | */ - + 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'noreply@example.com'), - 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Winter CMS')), + 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Winter CMS')), ], - ]; diff --git a/config/queue.php b/config/queue.php index ba40614d70..569d9ee426 100644 --- a/config/queue.php +++ b/config/queue.php @@ -1,7 +1,7 @@ env('QUEUE_CONNECTION', 'sync'), - + /* |-------------------------------------------------------------------------- | Queue Connections @@ -27,52 +27,46 @@ | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" | */ - + 'connections' => [ - 'sync' => [ 'driver' => 'sync', ], - 'database' => [ 'after_commit' => false, - 'driver' => 'database', - 'queue' => 'default', - 'retry_after' => 90, - 'table' => 'jobs', + 'driver' => 'database', + 'queue' => 'default', + 'retry_after' => 90, + 'table' => 'jobs', ], - 'beanstalkd' => [ 'after_commit' => false, - 'block_for' => 0, - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, + 'block_for' => 0, + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'retry_after' => 90, ], - 'sqs' => [ 'after_commit' => false, - 'driver' => 'sqs', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), - 'queue' => env('SQS_QUEUE', 'default'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'suffix' => env('SQS_SUFFIX'), + 'driver' => 'sqs', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'default'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'suffix' => env('SQS_SUFFIX'), ], - 'redis' => [ 'after_commit' => false, - 'block_for' => null, - 'connection' => 'default', - 'driver' => 'redis', - 'queue' => env('REDIS_QUEUE', 'default'), - 'retry_after' => 90, + 'block_for' => null, + 'connection' => 'default', + 'driver' => 'redis', + 'queue' => env('REDIS_QUEUE', 'default'), + 'retry_after' => 90, ], - ], - + /* |-------------------------------------------------------------------------- | Failed Queue Jobs @@ -83,11 +77,10 @@ | have failed. You may change them to any database / table you wish. | */ - + 'failed' => [ 'database' => env('DB_CONNECTION', 'mysql'), - 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), - 'table' => 'failed_jobs', + 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), + 'table' => 'failed_jobs', ], - ]; diff --git a/config/services.php b/config/services.php index 32760c1d49..d2cf8694bb 100644 --- a/config/services.php +++ b/config/services.php @@ -1,7 +1,7 @@ [ - 'domain' => env('MAILGUN_DOMAIN'), + 'domain' => env('MAILGUN_DOMAIN'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), - 'secret' => env('MAILGUN_SECRET'), + 'secret' => env('MAILGUN_SECRET'), ], - 'postmark' => [ 'token' => env('POSTMARK_TOKEN'), ], - 'ses' => [ - 'key' => env('AWS_ACCESS_KEY_ID'), + 'key' => env('AWS_ACCESS_KEY_ID'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), ], - ]; diff --git a/config/session.php b/config/session.php index 78aac1472e..73b725aaf9 100644 --- a/config/session.php +++ b/config/session.php @@ -1,7 +1,7 @@ env('SESSION_DRIVER', 'file'), - + /* |-------------------------------------------------------------------------- | Session Lifetime @@ -28,11 +28,10 @@ | to immediately expire on the browser closing, set that option. | */ - + 'lifetime' => env('SESSION_LIFETIME', 120), - 'expire_on_close' => false, - + /* |-------------------------------------------------------------------------- | Session Encryption @@ -43,9 +42,9 @@ | automatically by Laravel and you can use the Session like normal. | */ - + 'encrypt' => false, - + /* |-------------------------------------------------------------------------- | Session File Location @@ -56,9 +55,9 @@ | location may be specified. This is only needed for file sessions. | */ - + 'files' => storage_path('framework/sessions'), - + /* |-------------------------------------------------------------------------- | Session Database Connection @@ -69,9 +68,9 @@ | correspond to a connection in your database configuration options. | */ - + 'connection' => env('SESSION_CONNECTION'), - + /* |-------------------------------------------------------------------------- | Session Database Table @@ -82,9 +81,9 @@ | provided for you; however, you are free to change this as needed. | */ - + 'table' => 'sessions', - + /* |-------------------------------------------------------------------------- | Session Cache Store @@ -97,9 +96,9 @@ | Affects: "apc", "dynamodb", "memcached", "redis" | */ - + 'store' => env('SESSION_STORE'), - + /* |-------------------------------------------------------------------------- | Session Sweeping Lottery @@ -110,9 +109,12 @@ | happen on a given request. By default, the odds are 2 out of 100. | */ - - 'lottery' => [2, 100], - + + 'lottery' => [ + 2, + 100, + ], + /* |-------------------------------------------------------------------------- | Session Cookie Name @@ -123,12 +125,9 @@ | new session cookie is created by the framework for every driver. | */ - - 'cookie' => env( - 'SESSION_COOKIE', - str_slug(env('APP_NAME', 'winter'), '_').'_session' - ), - + + 'cookie' => env('SESSION_COOKIE', str_slug(env('APP_NAME', 'winter'), '_') . '_session'), + /* |-------------------------------------------------------------------------- | Session Cookie Path @@ -139,9 +138,9 @@ | your application but you are free to change this when necessary. | */ - + 'path' => '/', - + /* |-------------------------------------------------------------------------- | Session Cookie Domain @@ -152,9 +151,9 @@ | available to in your application. A sensible default has been set. | */ - + 'domain' => env('SESSION_DOMAIN'), - + /* |-------------------------------------------------------------------------- | HTTP Access Only @@ -165,9 +164,9 @@ | the HTTP protocol. You are free to modify this option if needed. | */ - + 'http_only' => true, - + /* |-------------------------------------------------------------------------- | HTTPS Only Cookies @@ -178,9 +177,9 @@ | the cookie from being sent to you when it can't be done securely. | */ - + 'secure' => env('SESSION_SECURE_COOKIE', false), - + /* |-------------------------------------------------------------------------- | Same-Site Cookies @@ -212,7 +211,6 @@ | Supported: "lax", "strict", "none", null | */ - + 'same_site' => 'lax', - ]; diff --git a/config/view.php b/config/view.php index bbbb7327e0..e38f47fd31 100644 --- a/config/view.php +++ b/config/view.php @@ -1,7 +1,7 @@ [ - // Default Laravel Blade template location - // @see https://github.com/octobercms/october/issues/3473 & https://github.com/octobercms/october/issues/3459 - // realpath(base_path('resources/views')) - ], - + + 'paths' => [], + /* |-------------------------------------------------------------------------- | Compiled View Path @@ -29,10 +25,6 @@ | directory. However, as usual, you are free to change this value. | */ - - 'compiled' => env( - 'VIEW_COMPILED_PATH', - realpath(storage_path('framework/views')) - ), - + + 'compiled' => env('VIEW_COMPILED_PATH', realpath(storage_path('framework/views'))), ]; From eaf3d516695cc59ad7dcad76512af8ee24dfc4a0 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Thu, 17 Feb 2022 11:17:33 -0600 Subject: [PATCH 06/16] Bring in line with changes to the storm PR --- modules/system/console/WinterEnv.php | 63 +++++++++++++++++----------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/modules/system/console/WinterEnv.php b/modules/system/console/WinterEnv.php index 4bc9ddca45..d015106884 100644 --- a/modules/system/console/WinterEnv.php +++ b/modules/system/console/WinterEnv.php @@ -2,8 +2,8 @@ use App; use Illuminate\Console\Command; -use Winter\Storm\Config\ConfigFile; -use Winter\Storm\Config\EnvFile; +use Winter\Storm\Parse\EnvFile; +use Winter\Storm\Parse\PHP\ArrayFile; /** * Console command to convert configuration to use .env files. @@ -48,11 +48,6 @@ class WinterEnv extends Command */ protected $connection; - /** - * @var string env file name - */ - protected $envFile = '.env'; - /** * Create a new command instance. */ @@ -70,32 +65,22 @@ public function __construct() */ public function handle(): int { - if (file_exists($this->getEnvPath())) { + if (file_exists($this->laravel->environmentFilePath())) { $this->error('.env file already exists.'); return 1; } - $env = EnvFile::read($this->getEnvPath()); + $env = EnvFile::open($this->laravel->environmentFilePath()); $this->setEnvValues($env); $env->write(); $this->updateConfig(); - $this->info('.env configuration file has been created.'); return 0; } - /** - * Get the full path of the env file - * @return string - */ - protected function getEnvPath(): string - { - return base_path($this->envFile); - } - /** * Get the full path of a config file * @param string $config @@ -125,7 +110,35 @@ protected function setEnvValues(EnvFile $env): void } } } - $env->addNewLine(); + $env->addEmptyLine(); + } + } + + /** + * Update config files with env function calls + * @return void + */ + protected function updateConfig(): void + { + foreach ($this->config() as $config => $items) { + $arrayFile = ArrayFile::open($this->getConfigPath($config)); + foreach ($items as $envKey => $configKey) { + $arrayFile->set( + $configKey, + $arrayFile->function('env', $this->getEnvArgs($envKey, $config . '.' . $configKey)) + ); + if ($config === 'database' && $envKey === 'DB_CONNECTION') { + foreach ($this->dbConfig() as $connection => $keys) { + foreach ($keys as $dbEnvKey => $dbConfigKey) { + $path = sprintf('connections.%s.%s', $connection, $dbConfigKey); + $arrayFile->set( + $path, + $arrayFile->function('env', $this->getEnvArgs($dbEnvKey, $config . '.' . $path)) + ); + } + } + } + } } } @@ -134,7 +147,7 @@ protected function setEnvValues(EnvFile $env): void */ protected function writeDbEnvSettings($line) { - if ($this->connection == config('database.default') || $this->connection == 'redis') { + if ($this->connection === config('database.default') || $this->connection === 'redis') { $this->writeToEnv($line); } } @@ -147,7 +160,7 @@ protected function envValue($configKey) { $value = config("$this->config.$configKey"); - if ($this->config == 'database') { + if ($this->config === 'database') { $value = $this->databaseConfigValue($configKey); } @@ -160,15 +173,15 @@ protected function envValue($configKey) */ protected function databaseConfigValue($configKey) { - if ($configKey == 'default') { + if ($configKey === 'default') { return config('database.default'); } - if ($this->connection == 'redis') { + if ($this->connection === 'redis') { return config("database.redis.default.$configKey"); } - return config("database.connections.$this->connection.$configKey"); + return config("database.connections.{$this->connection}.$configKey"); } /** From d5871f3b2eaf9f5d2e0e6574676b97020cd2cd0f Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Thu, 17 Feb 2022 11:25:49 -0600 Subject: [PATCH 07/16] Fix botched merge --- modules/system/console/WinterEnv.php | 61 +--------------------------- 1 file changed, 1 insertion(+), 60 deletions(-) diff --git a/modules/system/console/WinterEnv.php b/modules/system/console/WinterEnv.php index d015106884..31c9d0c712 100644 --- a/modules/system/console/WinterEnv.php +++ b/modules/system/console/WinterEnv.php @@ -139,66 +139,7 @@ protected function updateConfig(): void } } } - } - } - - /** - * @param $line - */ - protected function writeDbEnvSettings($line) - { - if ($this->connection === config('database.default') || $this->connection === 'redis') { - $this->writeToEnv($line); - } - } - - /** - * @param $configKey - * @return string - */ - protected function envValue($configKey) - { - $value = config("$this->config.$configKey"); - - if ($this->config === 'database') { - $value = $this->databaseConfigValue($configKey); - } - - return $value; - } - - /** - * @param $configKey - * @return string - */ - protected function databaseConfigValue($configKey) - { - if ($configKey === 'default') { - return config('database.default'); - } - - if ($this->connection === 'redis') { - return config("database.redis.default.$configKey"); - } - - return config("database.connections.{$this->connection}.$configKey"); - } - - /** - * Normalizes a value to be inserted into the .env file - * - * @param $value - * @return string - */ - protected function normalizeForEnv($value) - { - if (is_string($value)) { - if (preg_match('/["\'#]/', $value)) { - return '"' . str_replace('"', '\\"', $value) . '"'; - } else { - return $value; - } - $conf->write(); + $arrayFile->write(); } } From 674ee3294780392c22bde096b2817695f9c86a2a Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Thu, 17 Feb 2022 12:36:15 -0600 Subject: [PATCH 08/16] Fix winter:env test --- modules/system/console/WinterEnv.php | 50 ++++++++----------- tests/fixtures/config/app.php | 2 +- tests/fixtures/config/mail.php | 2 +- tests/unit/system/console/WinterEnvTest.php | 54 ++++++++++----------- 4 files changed, 48 insertions(+), 60 deletions(-) diff --git a/modules/system/console/WinterEnv.php b/modules/system/console/WinterEnv.php index 31c9d0c712..c7356cdd83 100644 --- a/modules/system/console/WinterEnv.php +++ b/modules/system/console/WinterEnv.php @@ -38,16 +38,6 @@ class WinterEnv extends Command 'REDIS_PASSWORD', ]; - /** - * The current config cursor. - */ - protected $config; - - /** - * The current database connection cursor. - */ - protected $connection; - /** * Create a new command instance. */ @@ -66,15 +56,12 @@ public function __construct() public function handle(): int { if (file_exists($this->laravel->environmentFilePath())) { - $this->error('.env file already exists.'); + $this->error('.env file already exists (' . $this->laravel->environmentFilePath() . ')'); return 1; } - $env = EnvFile::open($this->laravel->environmentFilePath()); - $this->setEnvValues($env); - $env->write(); - - $this->updateConfig(); + $this->updateEnvFile(); + $this->updateConfigFiles(); $this->info('.env configuration file has been created.'); @@ -93,11 +80,11 @@ protected function getConfigPath(string $config): string /** * Set env keys to their config values within the EnvFile object - * @param EnvFile $env - * @return void */ - protected function setEnvValues(EnvFile $env): void + protected function updateEnvFile(): void { + $env = EnvFile::open($this->laravel->environmentFilePath()); + foreach ($this->config() as $config => $items) { foreach ($items as $envKey => $configKey) { $env->set($envKey, config($config . '.' . $configKey)); @@ -112,20 +99,21 @@ protected function setEnvValues(EnvFile $env): void } $env->addEmptyLine(); } + + $env->write(); } /** * Update config files with env function calls - * @return void */ - protected function updateConfig(): void + protected function updateConfigFiles(): void { foreach ($this->config() as $config => $items) { $arrayFile = ArrayFile::open($this->getConfigPath($config)); foreach ($items as $envKey => $configKey) { $arrayFile->set( $configKey, - $arrayFile->function('env', $this->getEnvArgs($envKey, $config . '.' . $configKey)) + $arrayFile->function('env', $this->getKeyValuePair($envKey, $config . '.' . $configKey)) ); if ($config === 'database' && $envKey === 'DB_CONNECTION') { foreach ($this->dbConfig() as $connection => $keys) { @@ -133,7 +121,7 @@ protected function updateConfig(): void $path = sprintf('connections.%s.%s', $connection, $dbConfigKey); $arrayFile->set( $path, - $arrayFile->function('env', $this->getEnvArgs($dbEnvKey, $config . '.' . $path)) + $arrayFile->function('env', $this->getKeyValuePair($dbEnvKey, $config . '.' . $path)) ); } } @@ -144,14 +132,14 @@ protected function updateConfig(): void } /** - * Return an array used to generate the arguments for an env function call with protection of specific keys - * @param string $envConfig - * @param string $path - * @return array + * Returns an array containing the key as the first element and the value + * as the second if the key is not a protected key; otherwise the value + * will be an empty string */ - protected function getEnvArgs(string $envConfig, string $path): array + protected function getKeyValuePair(string $envKey, string $configKey): array { - return [$envConfig, in_array($envConfig, $this->protectedKeys) ? '' : config($path)]; + $return = [$envKey, in_array($envKey, $this->protectedKeys) ? '' : config($configKey)]; + return $return; } /** @@ -179,7 +167,7 @@ protected function config(): array 'QUEUE_CONNECTION' => 'default', ], 'mail' => [ - 'MAIL_DRIVER' => 'driver', + 'MAIL_MAILER' => 'default', 'MAIL_HOST' => 'host', 'MAIL_PORT' => 'port', 'MAIL_USERNAME' => 'username', @@ -191,7 +179,7 @@ protected function config(): array 'ASSET_CACHE' => 'enableAssetCache', 'LINK_POLICY' => 'linkPolicy', 'ENABLE_CSRF' => 'enableCsrfProtection', - 'DATABASE_TEMPLATES' => 'databaseTemplates' + 'DATABASE_TEMPLATES' => 'databaseTemplates', ], ]; } diff --git a/tests/fixtures/config/app.php b/tests/fixtures/config/app.php index 26032b4db7..98d819f130 100644 --- a/tests/fixtures/config/app.php +++ b/tests/fixtures/config/app.php @@ -3,7 +3,7 @@ return [ 'debug' => true, - 'url' => 'https://localhost', + 'url' => 'https://env-test.localhost', 'key' => 'CHANGE_ME!!!!!!!!!!!!!!!!!!!!!!!', 'timezone' => 'UTC', ]; diff --git a/tests/fixtures/config/mail.php b/tests/fixtures/config/mail.php index 281e9dac28..7620ae57ef 100644 --- a/tests/fixtures/config/mail.php +++ b/tests/fixtures/config/mail.php @@ -2,7 +2,7 @@ // Fixture used for `winter:env` unit tests in `tests/unit/system/console/WinterEnvTest.php return [ - 'driver' => 'smtp', + 'default' => 'smtp', 'host' => 'smtp.mailgun.org', 'port' => 587, 'encryption' => 'tls', diff --git a/tests/unit/system/console/WinterEnvTest.php b/tests/unit/system/console/WinterEnvTest.php index 6fe855bcb9..c75ad544e2 100644 --- a/tests/unit/system/console/WinterEnvTest.php +++ b/tests/unit/system/console/WinterEnvTest.php @@ -2,7 +2,7 @@ use Winter\Storm\Foundation\Bootstrap\LoadConfiguration; use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Console\Output\BufferedOutput; use System\Console\WinterEnv; class WinterEnvTest extends TestCase @@ -13,25 +13,33 @@ class WinterEnvTest extends TestCase /** @var string Stores the original config path from the app container */ public static $origConfigPath; + /** @var string Stores the original environment path from the app container */ + public static $origEnvPath; + protected function setUp(): void { parent::setUp(); $this->setUpConfigFixtures(); - $this->stubOutEnvFile(); } public function testCommand() { + $output = new BufferedOutput(); $command = new WinterEnv(); $command->setLaravel($this->app); - $command->run(new ArrayInput([]), new NullOutput); + $result = $command->run(new ArrayInput([]), $output); + + // Ensure that the command actually succeeded + if ($result !== 0) { + throw new \Exception("Command failed: \r\n" . $output->fetch()); + } // Check environment file - $envFile = file_get_contents(base_path('.env')); + $envFile = file_get_contents($this->app->environmentFilePath()); $this->assertStringContainsString('APP_DEBUG=true', $envFile); - $this->assertStringContainsString('APP_URL="https://localhost"', $envFile); + $this->assertStringContainsString('APP_URL="https://env-test.localhost"', $envFile); $this->assertStringContainsString('DB_CONNECTION="mysql"', $envFile); $this->assertStringContainsString('DB_DATABASE="data#base"', $envFile); $this->assertStringContainsString('DB_USERNAME="teal\'c"', $envFile); @@ -42,7 +50,7 @@ public function testCommand() $appConfigFile = file_get_contents(storage_path('temp/tests/config/app.php')); $this->assertStringContainsString('\'debug\' => env(\'APP_DEBUG\', true),', $appConfigFile); - $this->assertStringContainsString('\'url\' => env(\'APP_URL\', \'https://localhost\'),', $appConfigFile); + $this->assertStringContainsString('\'url\' => env(\'APP_URL\', \'https://env-test.localhost\'),', $appConfigFile); // Check database.php config file $appConfigFile = file_get_contents(storage_path('temp/tests/config/database.php')); @@ -58,7 +66,6 @@ public function testCommand() protected function tearDown(): void { $this->tearDownConfigFixtures(); - $this->restoreEnvFile(); parent::tearDown(); } @@ -69,6 +76,9 @@ protected function setUpConfigFixtures() if (!is_dir(storage_path('temp/tests/config'))) { mkdir(storage_path('temp/tests/config'), 0777, true); } + if (!is_dir(storage_path('temp/tests/env'))) { + mkdir(storage_path('temp/tests/env'), 0777, true); + } foreach (glob(base_path('tests/fixtures/config/*.php')) as $file) { $path = pathinfo($file); @@ -79,8 +89,10 @@ protected function setUpConfigFixtures() // Store original config path static::$origConfigPath = $this->app->make('path.config'); + static::$origEnvPath = $this->app->environmentPath(); $this->app->instance('path.config', storage_path('temp/tests/config')); + $this->app->useEnvironmentPath(storage_path('temp/tests/env')); // Re-load configuration $configBootstrap = new LoadConfiguration; @@ -95,6 +107,8 @@ protected function tearDownConfigFixtures() unlink($file); } rmdir(storage_path('temp/tests/config')); + unlink(storage_path('temp/tests/env/.env')); + rmdir(storage_path('temp/tests/env')); rmdir(storage_path('temp/tests')); static::$fixturesCopied = false; @@ -103,31 +117,17 @@ protected function tearDownConfigFixtures() // Restore config path if (self::$origConfigPath) { $this->app->instance('path.config', static::$origConfigPath); - static::$origConfigPath = null; } + // Restore environment path + if (self::$origEnvPath) { + $this->app->useEnvironmentPath(static::$origEnvPath); + static::$origEnvPath = null; + } + // Re-load configuration $configBootstrap = new LoadConfiguration; $configBootstrap->bootstrap($this->app); } - - protected function stubOutEnvFile() - { - if (file_exists(base_path('.env.stub'))) { - unlink(base_path('.env.stub')); - } - if (file_exists(base_path('.env'))) { - rename(base_path('.env'), base_path('.env.stub')); - } - } - - protected function restoreEnvFile() - { - unlink(base_path('.env')); - - if (file_exists(base_path('.env.stub'))) { - rename(base_path('.env.stub'), base_path('.env')); - } - } } From c3bdfae664c1cdde2ea1403027fc38b0822a0cf5 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Thu, 17 Feb 2022 12:38:51 -0600 Subject: [PATCH 09/16] Run the default config through ArrayFile parser This serves the dual purpose of both testing the output of the ArrayFile parser and normalizing the configs so that any future uses of ArrayFile on them will have easier to understand diffs. These were generated by running the following in Tinker: use Winter\Storm\Parse\PHP\ArrayFile; $configPaths = glob(base_path('config/*')); foreach ($configPaths as $path) { if (is_file($path)) { ArrayFile::open($path)->write(); } } --- config/app.php | 74 +++++++++---------- config/auth.php | 56 ++++++++------- config/broadcasting.php | 35 ++++----- config/cache.php | 64 +++++++---------- config/cms.php | 152 ++++++++++++++++++++-------------------- config/cookie.php | 9 +-- config/database.php | 119 ++++++++++++++----------------- config/develop.php | 9 ++- config/environment.php | 11 ++- config/filesystems.php | 30 ++++---- config/hashing.php | 17 +++-- config/logging.php | 72 +++++++++---------- config/mail.php | 40 +++++------ config/queue.php | 65 ++++++++--------- config/services.php | 13 ++-- config/session.php | 68 +++++++++--------- config/view.php | 20 ++---- 17 files changed, 385 insertions(+), 469 deletions(-) diff --git a/config/app.php b/config/app.php index 4ba2ad7f91..813e09110e 100644 --- a/config/app.php +++ b/config/app.php @@ -1,7 +1,7 @@ env('APP_DEBUG', true), - + /* |-------------------------------------------------------------------------- | Application Name @@ -28,9 +28,9 @@ | any other location as required by the application or its packages. | */ - + 'name' => env('APP_NAME', 'Winter CMS'), - + /* |-------------------------------------------------------------------------- | Application URL @@ -41,9 +41,9 @@ | your application so that it is used when running Artisan tasks. | */ - + 'url' => env('APP_URL', 'http://localhost'), - + /* |-------------------------------------------------------------------------- | Asset URL @@ -57,9 +57,9 @@ | 'asset_url' => 'https://cdn.example.com/', | */ - + 'asset_url' => env('ASSET_URL', null), - + /* |-------------------------------------------------------------------------- | Trusted hosts @@ -87,9 +87,9 @@ | NOTE: Even when set to `false`, this functionality is explicitly enabled | on the Backend password reset flow for security reasons. */ - + 'trustedHosts' => false, - + /* |-------------------------------------------------------------------------- | Trusted proxies @@ -115,9 +115,9 @@ | 'trustedProxies' => '192.168.1.1, 192.168.1.2' | 'trustedProxies' => ['192.168.1.1', '192.168.1.2'] */ - + 'trustedProxies' => null, - + /* |-------------------------------------------------------------------------- | Trusted proxy headers @@ -150,9 +150,9 @@ | | - Amazon ELB users should always use the "HEADER_X_FORWARDED_AWS_ELB" option. */ - + 'trustedProxyHeaders' => 'HEADER_X_FORWARDED_ALL', - + /* |-------------------------------------------------------------------------- | Application Timezone @@ -171,9 +171,9 @@ | to display dates & times. | */ - + 'timezone' => 'UTC', - + /* |-------------------------------------------------------------------------- | Application Locale Configuration @@ -190,9 +190,9 @@ | Backend\Models\Preference->getLocaleOptions() | */ - + 'locale' => 'en', - + /* |-------------------------------------------------------------------------- | Application Fallback Locale @@ -203,9 +203,9 @@ | the language folders that are provided through your application. | */ - + 'fallback_locale' => 'en', - + /* |-------------------------------------------------------------------------- | Faker Locale @@ -216,9 +216,9 @@ | localized telephone numbers, street address information and more. | */ - + 'faker_locale' => 'en_US', - + /* |-------------------------------------------------------------------------- | Encryption Key @@ -229,11 +229,10 @@ | will not be safe. Please do this before deploying an application! | */ - + 'key' => env('APP_KEY'), - 'cipher' => 'AES-256-CBC', - + /* |-------------------------------------------------------------------------- | Autoloaded Service Providers @@ -244,14 +243,12 @@ | this array to grant expanded functionality to your applications. | */ - - 'providers' => array_merge(include(base_path('modules/system/providers.php')), [ - + + 'providers' => array_merge(include base_path('modules/system/providers.php'), [ // 'Illuminate\Html\HtmlServiceProvider', // Example - - 'System\ServiceProvider', + 'System\\ServiceProvider', ]), - + /* |-------------------------------------------------------------------------- | Load automatically discovered packages @@ -269,9 +266,9 @@ | even if discovery is disabled. | */ - + 'loadDiscoveredPackages' => false, - + /* |-------------------------------------------------------------------------- | Class Aliases @@ -282,11 +279,6 @@ | the aliases are "lazy" loaded so they don't hinder performance. | */ - - 'aliases' => array_merge(include(base_path('modules/system/aliases.php')), [ - - // 'Str' => 'Illuminate\Support\Str', // Example - - ]), - + + 'aliases' => array_merge(include base_path('modules/system/aliases.php'), []), ]; diff --git a/config/auth.php b/config/auth.php index 8dc13b61c7..2acc88e6b4 100644 --- a/config/auth.php +++ b/config/auth.php @@ -1,39 +1,41 @@ [ + /* - |-------------------------------------------------------------------------- - | Enable throttling of Backend authentication attempts - |-------------------------------------------------------------------------- - | - | If set to true, users will be given a limited number of attempts to sign - | in to the Backend before being blocked for a specified number of minutes. - | - */ + |-------------------------------------------------------------------------- + | Enable throttling of Backend authentication attempts + |-------------------------------------------------------------------------- + | + | If set to true, users will be given a limited number of attempts to sign + | in to the Backend before being blocked for a specified number of minutes. + | + */ + 'enabled' => true, - + /* - |-------------------------------------------------------------------------- - | Failed Authentication Attempt Limit - |-------------------------------------------------------------------------- - | - | Number of failed attempts allowed while trying to authenticate a user. - | - */ + |-------------------------------------------------------------------------- + | Failed Authentication Attempt Limit + |-------------------------------------------------------------------------- + | + | Number of failed attempts allowed while trying to authenticate a user. + | + */ + 'attemptLimit' => 5, - + /* - |-------------------------------------------------------------------------- - | Suspension Time - |-------------------------------------------------------------------------- - | - | The number of minutes to suspend further attempts on authentication once - | the attempt limit is reached. - | - */ + |-------------------------------------------------------------------------- + | Suspension Time + |-------------------------------------------------------------------------- + | + | The number of minutes to suspend further attempts on authentication once + | the attempt limit is reached. + | + */ + 'suspensionTime' => 15, ], - ]; diff --git a/config/broadcasting.php b/config/broadcasting.php index 542f5f1de3..4210685ba4 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -1,7 +1,7 @@ env('BROADCAST_DRIVER', 'null'), - + /* |-------------------------------------------------------------------------- | Broadcast Connections @@ -27,41 +27,32 @@ | each available type of connection are provided inside this array. | */ - + 'connections' => [ - 'pusher' => [ - 'app_id' => env('PUSHER_APP_ID'), - 'client_options' => [ - // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html - ], - 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY'), - 'options' => [ + 'app_id' => env('PUSHER_APP_ID'), + 'client_options' => [], + 'driver' => 'pusher', + 'key' => env('PUSHER_APP_KEY'), + 'options' => [ 'cluster' => env('PUSHER_APP_CLUSTER'), - 'useTLS' => true, + 'useTLS' => true, ], - 'secret' => env('PUSHER_APP_SECRET'), + 'secret' => env('PUSHER_APP_SECRET'), ], - 'ably' => [ 'driver' => 'ably', - 'key' => env('ABLY_KEY'), + 'key' => env('ABLY_KEY'), ], - 'redis' => [ 'connection' => 'default', - 'driver' => 'redis', + 'driver' => 'redis', ], - 'log' => [ 'driver' => 'log', ], - 'null' => [ 'driver' => 'null', ], - ], - ]; diff --git a/config/cache.php b/config/cache.php index e2bba31603..22597b4cd3 100644 --- a/config/cache.php +++ b/config/cache.php @@ -1,7 +1,7 @@ env('CACHE_DRIVER', 'file'), - + /* |-------------------------------------------------------------------------- | Cache Stores @@ -33,41 +33,34 @@ | "memcached", "redis", "dynamodb", "octane", "null" | */ - + 'stores' => [ - 'apc' => [ 'driver' => 'apc', ], - 'array' => [ - 'driver' => 'array', + 'driver' => 'array', 'serialize' => false, ], - 'database' => [ - 'connection' => null, - 'driver' => 'database', + 'connection' => null, + 'driver' => 'database', 'lock_connection' => null, - 'table' => 'cache', + 'table' => 'cache', ], - 'file' => [ 'driver' => 'file', - 'path' => storage_path('framework/cache'), + 'path' => storage_path('framework/cache'), ], - 'memcached' => [ - 'driver' => 'memcached', - 'options' => [ - // Memcached::OPT_CONNECT_TIMEOUT => 2000, - ], + 'driver' => 'memcached', + 'options' => [], 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 'sasl' => [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], - 'servers' => [ + 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 'port' => env('MEMCACHED_PORT', 11211), @@ -75,28 +68,24 @@ ], ], ], - 'redis' => [ - 'connection' => 'cache', - 'driver' => 'redis', + 'connection' => 'cache', + 'driver' => 'redis', 'lock_connection' => 'default', ], - 'dynamodb' => [ - 'driver' => 'dynamodb', + 'driver' => 'dynamodb', 'endpoint' => env('DYNAMODB_ENDPOINT'), - 'key' => env('AWS_ACCESS_KEY_ID'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), ], - 'octane' => [ 'driver' => 'octane', ], - ], - + /* |-------------------------------------------------------------------------- | Cache Key Prefix @@ -107,9 +96,9 @@ | value to get prefixed to all our keys so we can avoid collisions. | */ - - 'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'winter'), '_').'_cache'), - + + 'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'winter'), '_') . '_cache'), + /* |-------------------------------------------------------------------------- | Cache Key for the CMS' PHP code parser cache @@ -121,9 +110,9 @@ | prevent conflicts. | */ - + 'codeParserDataCacheKey' => 'cms-php-file-data', - + /* |-------------------------------------------------------------------------- | Disable Request Cache @@ -143,7 +132,6 @@ | null - enable for HTTP requests, disable when running in CLI | */ - + 'disableRequestCache' => null, - ]; diff --git a/config/cms.php b/config/cms.php index 4da7fd4a7e..483d13fdfa 100644 --- a/config/cms.php +++ b/config/cms.php @@ -1,7 +1,7 @@ 'demo', - + /* |-------------------------------------------------------------------------- | Bleeding edge updates @@ -23,9 +23,9 @@ | and use the development copies of core files and plugins. | */ - + 'edgeUpdates' => false, - + /* |-------------------------------------------------------------------------- | Back-end URI prefix @@ -35,9 +35,9 @@ | For example: backend -> http://localhost/backend | */ - + 'backendUri' => 'backend', - + /* |-------------------------------------------------------------------------- | Back-end force HTTPS security @@ -48,9 +48,9 @@ | web server config, but can be handled by the app for added security. | */ - + 'backendForceSecure' => false, - + /* |-------------------------------------------------------------------------- | Back-end login remember @@ -66,9 +66,9 @@ | wanted behavior | */ - + 'backendForceRemember' => true, - + /* |-------------------------------------------------------------------------- | Back-end timezone @@ -79,9 +79,9 @@ | dates displayed in the back-end will be converted to this timezone. | */ - + 'backendTimezone' => 'UTC', - + /* |-------------------------------------------------------------------------- | Back-end Skin @@ -90,9 +90,9 @@ | Specifies the back-end skin to use. | */ - - 'backendSkin' => 'Backend\Skins\Standard', - + + 'backendSkin' => 'Backend\\Skins\\Standard', + /* |-------------------------------------------------------------------------- | Automatically run migrations on login @@ -105,9 +105,9 @@ | and disabled when debug mode is disabled. | */ - + 'runMigrationsOnLogin' => null, - + /* |-------------------------------------------------------------------------- | Determines which modules to load @@ -116,9 +116,13 @@ | Specify which modules should be registered when using the application. | */ - - 'loadModules' => ['System', 'Backend', 'Cms'], - + + 'loadModules' => [ + 'System', + 'Backend', + 'Cms', + ], + /* |-------------------------------------------------------------------------- | Prevents application updates @@ -130,9 +134,9 @@ | and themes will still be downloaded. | */ - + 'disableCoreUpdates' => false, - + /* |-------------------------------------------------------------------------- | Specific plugins to disable @@ -141,9 +145,9 @@ | Specify plugin codes which will always be disabled in the application. | */ - + 'disablePlugins' => [], - + /* |-------------------------------------------------------------------------- | Determines if the routing caching is enabled. @@ -155,9 +159,9 @@ | to disable the caching during the development, and enable it in the production mode. | */ - + 'enableRoutesCache' => false, - + /* |-------------------------------------------------------------------------- | Time to live for the URL map. @@ -168,9 +172,9 @@ | interval, in minutes, specified with the urlMapCacheTTL parameter expires. | */ - + 'urlCacheTtl' => 10, - + /* |-------------------------------------------------------------------------- | Time to live for parsed CMS objects. @@ -181,9 +185,9 @@ | the corresponding template file is modified. | */ - + 'parsedPageCacheTTL' => 10, - + /* |-------------------------------------------------------------------------- | Determines if the asset caching is enabled. @@ -195,9 +199,9 @@ | to disable the caching during the development, and enable it in the production mode. | */ - + 'enableAssetCache' => false, - + /* |-------------------------------------------------------------------------- | Determines if the asset minification is enabled. @@ -209,9 +213,9 @@ | when debug mode (app.debug) is disabled. | */ - + 'enableAssetMinify' => null, - + /* |-------------------------------------------------------------------------- | Check import timestamps when combining assets @@ -223,9 +227,9 @@ | is used when debug mode (app.debug) is enabled. | */ - + 'enableAssetDeepHashing' => null, - + /* |-------------------------------------------------------------------------- | Database-driven Themes @@ -249,9 +253,9 @@ | from the database. | */ - + 'databaseTemplates' => false, - + /* |-------------------------------------------------------------------------- | Public plugins path @@ -261,9 +265,9 @@ | or you can specify a full URL path. | */ - + 'pluginsPath' => '/plugins', - + /* |-------------------------------------------------------------------------- | Public themes path @@ -273,9 +277,9 @@ | or you can specify a full URL path. | */ - + 'themesPath' => '/themes', - + /* |-------------------------------------------------------------------------- | Resource storage @@ -310,30 +314,26 @@ | path for the uploads disk and `/projects/winter/storage/app/media` as | the path for the media disk. */ - + 'storage' => [ - 'uploads' => [ - 'disk' => 'local', - 'folder' => 'uploads', - 'path' => '/storage/app/uploads', + 'disk' => 'local', + 'folder' => 'uploads', + 'path' => '/storage/app/uploads', 'temporaryUrlTTL' => 3600, ], - 'media' => [ - 'disk' => 'local', + 'disk' => 'local', 'folder' => 'media', - 'path' => '/storage/app/media', + 'path' => '/storage/app/media', ], - 'resized' => [ - 'disk' => 'local', + 'disk' => 'local', 'folder' => 'resized', - 'path' => '/storage/app/resized', + 'path' => '/storage/app/resized', ], - ], - + /* |-------------------------------------------------------------------------- | Convert Line Endings @@ -343,9 +343,9 @@ | \r\n to the unix style \n. | */ - + 'convertLineEndings' => false, - + /* |-------------------------------------------------------------------------- | Linking policy @@ -359,9 +359,9 @@ | force - force hostname and schema using app.url config value | */ - + 'linkPolicy' => 'detect', - + /* |-------------------------------------------------------------------------- | Default permission mask @@ -370,9 +370,12 @@ | Specifies a default file and folder permission for newly created objects. | */ - - 'defaultMask' => ['file' => null, 'folder' => null], - + + 'defaultMask' => [ + 'file' => null, + 'folder' => null, + ], + /* |-------------------------------------------------------------------------- | Safe mode @@ -383,9 +386,9 @@ | debug mode (app.debug) is disabled. | */ - + 'enableSafeMode' => null, - + /* |-------------------------------------------------------------------------- | Cross Site Request Forgery (CSRF) Protection @@ -395,9 +398,9 @@ | checked for a valid security token. | */ - + 'enableCsrfProtection' => true, - + /* |-------------------------------------------------------------------------- | Force bytecode invalidation @@ -408,9 +411,9 @@ | cache won't update the cache, set to true to get around this. | */ - + 'forceBytecodeInvalidation' => true, - + /* |-------------------------------------------------------------------------- | Twig Strict Variables @@ -423,9 +426,9 @@ | enabled. | */ - + 'enableTwigStrictVariables' => false, - + /* |-------------------------------------------------------------------------- | Base Directory Restriction @@ -442,9 +445,9 @@ | NEVER have this disabled in production. | */ - + 'restrictBaseDir' => true, - + /* |-------------------------------------------------------------------------- | Backend Service Worker @@ -464,7 +467,6 @@ | false - disallow service workers to run in the backend | */ - + 'enableBackendServiceWorkers' => false, - ]; diff --git a/config/cookie.php b/config/cookie.php index f286fe5a6b..a6c8528d76 100644 --- a/config/cookie.php +++ b/config/cookie.php @@ -1,7 +1,7 @@ [ - // 'my_cookie', - ], - + + 'unencryptedCookies' => [], ]; diff --git a/config/database.php b/config/database.php index 2d612ab1ce..5d4bd6c398 100644 --- a/config/database.php +++ b/config/database.php @@ -1,7 +1,7 @@ env('DB_CONNECTION', 'mysql'), - + /* |-------------------------------------------------------------------------- | Database Connections @@ -29,68 +29,63 @@ | choice installed on your machine before you begin development. | */ - + 'connections' => [ - 'sqlite' => [ - 'database' => env('DB_DATABASE', storage_path('database.sqlite')), - 'driver' => 'sqlite', + 'database' => env('DB_DATABASE', storage_path('database.sqlite')), + 'driver' => 'sqlite', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), - 'prefix' => '', - 'url' => env('DATABASE_URL'), + 'prefix' => '', + 'url' => env('DATABASE_URL'), ], - 'mysql' => [ - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'mysql', - 'engine' => 'InnoDB', - 'host' => env('DB_HOST', '127.0.0.1'), - 'options' => extension_loaded('pdo_mysql') ? array_filter([ + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'mysql', + 'engine' => 'InnoDB', + 'host' => env('DB_HOST', '127.0.0.1'), + 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '3306'), - 'prefix' => '', + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '3306'), + 'prefix' => '', 'prefix_indexes' => true, - 'strict' => true, - 'unix_socket' => env('DB_SOCKET', ''), - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), - 'varcharmax' => 191, + 'strict' => true, + 'unix_socket' => env('DB_SOCKET', ''), + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), + 'varcharmax' => 191, ], - 'pgsql' => [ - 'charset' => 'utf8', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'pgsql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '5432'), - 'prefix' => '', + 'charset' => 'utf8', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'pgsql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '5432'), + 'prefix' => '', 'prefix_indexes' => true, - 'search_path' => 'public', - 'sslmode' => 'prefer', - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), + 'search_path' => 'public', + 'sslmode' => 'prefer', + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), ], - 'sqlsrv' => [ - 'charset' => 'utf8', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'sqlsrv', - 'host' => env('DB_HOST', '127.0.0.1'), - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '1433'), - 'prefix' => '', + 'charset' => 'utf8', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'sqlsrv', + 'host' => env('DB_HOST', '127.0.0.1'), + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '1433'), + 'prefix' => '', 'prefix_indexes' => true, - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), ], - ], - + /* |-------------------------------------------------------------------------- | Migration Repository Table @@ -101,9 +96,9 @@ | the migrations on disk haven't actually been run in the database. | */ - + 'migrations' => 'migrations', - + /* |-------------------------------------------------------------------------- | Redis Databases @@ -114,32 +109,26 @@ | such as APC or Memcached. Winter makes it easy to dig right in. | */ - + 'redis' => [ - 'client' => env('REDIS_CLIENT', 'phpredis'), - 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', str_slug(env('APP_NAME', 'winter'), '_').'_database_'), + 'prefix' => env('REDIS_PREFIX', str_slug(env('APP_NAME', 'winter'), '_') . '_database_'), ], - 'default' => [ 'database' => env('REDIS_DB', '0'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'url' => env('REDIS_URL'), + 'port' => env('REDIS_PORT', '6379'), + 'url' => env('REDIS_URL'), ], - 'cache' => [ 'database' => env('REDIS_CACHE_DB', '1'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'url' => env('REDIS_URL'), + 'port' => env('REDIS_PORT', '6379'), + 'url' => env('REDIS_URL'), ], - ], - ]; diff --git a/config/develop.php b/config/develop.php index 381b56409d..47c89175c8 100644 --- a/config/develop.php +++ b/config/develop.php @@ -1,7 +1,7 @@ false, - + /* |-------------------------------------------------------------------------- | Allow deep-level symlinks @@ -40,7 +40,6 @@ | false - only allow symlinks at the first level of subdirectories (default) | */ - + 'allowDeepSymlinks' => false, - ]; diff --git a/config/environment.php b/config/environment.php index 5249b15bad..fb17f634df 100644 --- a/config/environment.php +++ b/config/environment.php @@ -1,7 +1,7 @@ 'development', - + /* |-------------------------------------------------------------------------- | Environment Multitenancy @@ -25,11 +25,8 @@ | different configuration, such as database and theme, per hostname. | */ - + 'hosts' => [ - 'localhost' => 'dev', - ], - ]; diff --git a/config/filesystems.php b/config/filesystems.php index a85fcc8a9e..0fc1103700 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -1,7 +1,7 @@ env('FILESYSTEM_DISK', 'local'), - + /* |-------------------------------------------------------------------------- | Filesystem Disks @@ -27,26 +27,22 @@ | Supported Drivers: "local", "ftp", "sftp", "s3" | */ - + 'disks' => [ - 'local' => [ 'driver' => 'local', - 'root' => storage_path('app'), - 'url' => '/storage/app', + 'root' => storage_path('app'), + 'url' => '/storage/app', ], - 's3' => [ - 'bucket' => env('AWS_BUCKET'), - 'driver' => 's3', - 'endpoint' => env('AWS_ENDPOINT'), - 'key' => env('AWS_ACCESS_KEY_ID'), - 'region' => env('AWS_DEFAULT_REGION'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'url' => env('AWS_URL'), + 'bucket' => env('AWS_BUCKET'), + 'driver' => 's3', + 'endpoint' => env('AWS_ENDPOINT'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'region' => env('AWS_DEFAULT_REGION'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'url' => env('AWS_URL'), 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), ], - ], - ]; diff --git a/config/hashing.php b/config/hashing.php index 616059443b..f8c867896a 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -1,7 +1,7 @@ 'bcrypt', - + /* |-------------------------------------------------------------------------- | Bcrypt Options @@ -27,11 +27,11 @@ | to control the amount of time it takes to hash the given password. | */ - + 'bcrypt' => [ 'rounds' => env('BCRYPT_ROUNDS', 10), ], - + /* |-------------------------------------------------------------------------- | Argon Options @@ -42,11 +42,10 @@ | to control the amount of time it takes to hash the given password. | */ - + 'argon' => [ - 'memory' => 65536, + 'memory' => 65536, 'threads' => 1, - 'time' => 4, + 'time' => 4, ], - ]; diff --git a/config/logging.php b/config/logging.php index e7ea8f3bb6..e60a3fa51f 100644 --- a/config/logging.php +++ b/config/logging.php @@ -1,7 +1,7 @@ env('LOG_CHANNEL', 'stack'), - + /* |-------------------------------------------------------------------------- | Deprecations Log Channel @@ -25,9 +25,9 @@ | your application ready for upcoming major versions of dependencies. | */ - + 'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), - + /* |-------------------------------------------------------------------------- | Log Channels @@ -42,74 +42,66 @@ | "custom", "stack" | */ - + 'channels' => [ 'stack' => [ - 'channels' => ['single'], - 'driver' => 'stack', + 'channels' => [ + 'single', + ], + 'driver' => 'stack', 'ignore_exceptions' => false, ], - 'single' => [ 'driver' => 'single', - 'level' => env('LOG_LEVEL', 'debug'), - 'path' => storage_path('logs/system.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'path' => storage_path('logs/system.log'), ], - 'daily' => [ - 'days' => 14, + 'days' => 14, 'driver' => 'daily', - 'level' => env('LOG_LEVEL', 'debug'), - 'path' => storage_path('logs/system.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'path' => storage_path('logs/system.log'), ], - 'slack' => [ - 'driver' => 'slack', - 'emoji' => ':boom:', - 'level' => env('LOG_LEVEL', 'critical'), - 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'driver' => 'slack', + 'emoji' => ':boom:', + 'level' => env('LOG_LEVEL', 'critical'), + 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Winter Log', ], - 'papertrail' => [ - 'driver' => 'monolog', - 'handler' => env('LOG_PAPERTRAIL_HANDLER', \Monolog\Handler\SyslogUdpHandler::class), + 'driver' => 'monolog', + 'handler' => env('LOG_PAPERTRAIL_HANDLER', \Monolog\Handler\SyslogUdpHandler::class), 'handler_with' => [ - 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), - 'host' => env('PAPERTRAIL_URL'), - 'port' => env('PAPERTRAIL_PORT'), + 'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'), + 'host' => env('PAPERTRAIL_URL'), + 'port' => env('PAPERTRAIL_PORT'), ], - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], - 'stderr' => [ - 'driver' => 'monolog', + 'driver' => 'monolog', 'formatter' => env('LOG_STDERR_FORMATTER'), - 'handler' => \Monolog\Handler\StreamHandler::class, - 'level' => env('LOG_LEVEL', 'debug'), - 'with' => [ + 'handler' => \Monolog\Handler\StreamHandler::class, + 'level' => env('LOG_LEVEL', 'debug'), + 'with' => [ 'stream' => 'php://stderr', ], ], - 'syslog' => [ 'driver' => 'syslog', - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], - 'errorlog' => [ 'driver' => 'errorlog', - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], - 'null' => [ - 'driver' => 'monolog', + 'driver' => 'monolog', 'handler' => \Monolog\Handler\NullHandler::class, ], - 'emergency' => [ 'path' => storage_path('logs/system.log'), ], ], - ]; diff --git a/config/mail.php b/config/mail.php index 25a896d141..d1c10db337 100644 --- a/config/mail.php +++ b/config/mail.php @@ -1,7 +1,7 @@ env('MAIL_MAILER', 'smtp'), - + /* |-------------------------------------------------------------------------- | Mailer Configurations @@ -32,53 +32,46 @@ | "postmark", "log", "array", "failover" | */ - + 'mailers' => [ 'smtp' => [ 'encryption' => env('MAIL_ENCRYPTION', 'tls'), - 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), - 'password' => env('MAIL_PASSWORD'), - 'port' => env('MAIL_PORT', 587), - 'timeout' => null, - 'transport' => 'smtp', - 'username' => env('MAIL_USERNAME'), + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), + 'password' => env('MAIL_PASSWORD'), + 'port' => env('MAIL_PORT', 587), + 'timeout' => null, + 'transport' => 'smtp', + 'username' => env('MAIL_USERNAME'), ], - 'ses' => [ 'transport' => 'ses', ], - 'mailgun' => [ 'transport' => 'mailgun', ], - 'postmark' => [ 'transport' => 'postmark', ], - 'sendmail' => [ - 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), + 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), 'transport' => 'sendmail', ], - 'log' => [ - 'channel' => env('MAIL_LOG_CHANNEL'), + 'channel' => env('MAIL_LOG_CHANNEL'), 'transport' => 'log', ], - 'array' => [ 'transport' => 'array', ], - 'failover' => [ - 'mailers' => [ + 'mailers' => [ 'smtp', 'log', ], 'transport' => 'failover', ], ], - + /* |-------------------------------------------------------------------------- | Global "From" Address @@ -89,10 +82,9 @@ | used globally for all e-mails that are sent by your application. | */ - + 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'noreply@example.com'), - 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Winter CMS')), + 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Winter CMS')), ], - ]; diff --git a/config/queue.php b/config/queue.php index ba40614d70..569d9ee426 100644 --- a/config/queue.php +++ b/config/queue.php @@ -1,7 +1,7 @@ env('QUEUE_CONNECTION', 'sync'), - + /* |-------------------------------------------------------------------------- | Queue Connections @@ -27,52 +27,46 @@ | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" | */ - + 'connections' => [ - 'sync' => [ 'driver' => 'sync', ], - 'database' => [ 'after_commit' => false, - 'driver' => 'database', - 'queue' => 'default', - 'retry_after' => 90, - 'table' => 'jobs', + 'driver' => 'database', + 'queue' => 'default', + 'retry_after' => 90, + 'table' => 'jobs', ], - 'beanstalkd' => [ 'after_commit' => false, - 'block_for' => 0, - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, + 'block_for' => 0, + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'retry_after' => 90, ], - 'sqs' => [ 'after_commit' => false, - 'driver' => 'sqs', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), - 'queue' => env('SQS_QUEUE', 'default'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'suffix' => env('SQS_SUFFIX'), + 'driver' => 'sqs', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'default'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'suffix' => env('SQS_SUFFIX'), ], - 'redis' => [ 'after_commit' => false, - 'block_for' => null, - 'connection' => 'default', - 'driver' => 'redis', - 'queue' => env('REDIS_QUEUE', 'default'), - 'retry_after' => 90, + 'block_for' => null, + 'connection' => 'default', + 'driver' => 'redis', + 'queue' => env('REDIS_QUEUE', 'default'), + 'retry_after' => 90, ], - ], - + /* |-------------------------------------------------------------------------- | Failed Queue Jobs @@ -83,11 +77,10 @@ | have failed. You may change them to any database / table you wish. | */ - + 'failed' => [ 'database' => env('DB_CONNECTION', 'mysql'), - 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), - 'table' => 'failed_jobs', + 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), + 'table' => 'failed_jobs', ], - ]; diff --git a/config/services.php b/config/services.php index 32760c1d49..d2cf8694bb 100644 --- a/config/services.php +++ b/config/services.php @@ -1,7 +1,7 @@ [ - 'domain' => env('MAILGUN_DOMAIN'), + 'domain' => env('MAILGUN_DOMAIN'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), - 'secret' => env('MAILGUN_SECRET'), + 'secret' => env('MAILGUN_SECRET'), ], - 'postmark' => [ 'token' => env('POSTMARK_TOKEN'), ], - 'ses' => [ - 'key' => env('AWS_ACCESS_KEY_ID'), + 'key' => env('AWS_ACCESS_KEY_ID'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), ], - ]; diff --git a/config/session.php b/config/session.php index 78aac1472e..73b725aaf9 100644 --- a/config/session.php +++ b/config/session.php @@ -1,7 +1,7 @@ env('SESSION_DRIVER', 'file'), - + /* |-------------------------------------------------------------------------- | Session Lifetime @@ -28,11 +28,10 @@ | to immediately expire on the browser closing, set that option. | */ - + 'lifetime' => env('SESSION_LIFETIME', 120), - 'expire_on_close' => false, - + /* |-------------------------------------------------------------------------- | Session Encryption @@ -43,9 +42,9 @@ | automatically by Laravel and you can use the Session like normal. | */ - + 'encrypt' => false, - + /* |-------------------------------------------------------------------------- | Session File Location @@ -56,9 +55,9 @@ | location may be specified. This is only needed for file sessions. | */ - + 'files' => storage_path('framework/sessions'), - + /* |-------------------------------------------------------------------------- | Session Database Connection @@ -69,9 +68,9 @@ | correspond to a connection in your database configuration options. | */ - + 'connection' => env('SESSION_CONNECTION'), - + /* |-------------------------------------------------------------------------- | Session Database Table @@ -82,9 +81,9 @@ | provided for you; however, you are free to change this as needed. | */ - + 'table' => 'sessions', - + /* |-------------------------------------------------------------------------- | Session Cache Store @@ -97,9 +96,9 @@ | Affects: "apc", "dynamodb", "memcached", "redis" | */ - + 'store' => env('SESSION_STORE'), - + /* |-------------------------------------------------------------------------- | Session Sweeping Lottery @@ -110,9 +109,12 @@ | happen on a given request. By default, the odds are 2 out of 100. | */ - - 'lottery' => [2, 100], - + + 'lottery' => [ + 2, + 100, + ], + /* |-------------------------------------------------------------------------- | Session Cookie Name @@ -123,12 +125,9 @@ | new session cookie is created by the framework for every driver. | */ - - 'cookie' => env( - 'SESSION_COOKIE', - str_slug(env('APP_NAME', 'winter'), '_').'_session' - ), - + + 'cookie' => env('SESSION_COOKIE', str_slug(env('APP_NAME', 'winter'), '_') . '_session'), + /* |-------------------------------------------------------------------------- | Session Cookie Path @@ -139,9 +138,9 @@ | your application but you are free to change this when necessary. | */ - + 'path' => '/', - + /* |-------------------------------------------------------------------------- | Session Cookie Domain @@ -152,9 +151,9 @@ | available to in your application. A sensible default has been set. | */ - + 'domain' => env('SESSION_DOMAIN'), - + /* |-------------------------------------------------------------------------- | HTTP Access Only @@ -165,9 +164,9 @@ | the HTTP protocol. You are free to modify this option if needed. | */ - + 'http_only' => true, - + /* |-------------------------------------------------------------------------- | HTTPS Only Cookies @@ -178,9 +177,9 @@ | the cookie from being sent to you when it can't be done securely. | */ - + 'secure' => env('SESSION_SECURE_COOKIE', false), - + /* |-------------------------------------------------------------------------- | Same-Site Cookies @@ -212,7 +211,6 @@ | Supported: "lax", "strict", "none", null | */ - + 'same_site' => 'lax', - ]; diff --git a/config/view.php b/config/view.php index bbbb7327e0..e38f47fd31 100644 --- a/config/view.php +++ b/config/view.php @@ -1,7 +1,7 @@ [ - // Default Laravel Blade template location - // @see https://github.com/octobercms/october/issues/3473 & https://github.com/octobercms/october/issues/3459 - // realpath(base_path('resources/views')) - ], - + + 'paths' => [], + /* |-------------------------------------------------------------------------- | Compiled View Path @@ -29,10 +25,6 @@ | directory. However, as usual, you are free to change this value. | */ - - 'compiled' => env( - 'VIEW_COMPILED_PATH', - realpath(storage_path('framework/views')) - ), - + + 'compiled' => env('VIEW_COMPILED_PATH', realpath(storage_path('framework/views'))), ]; From 33441c0987fc78d2d9e0ceafea0ad881a20e2b0d Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Thu, 17 Feb 2022 20:20:43 -0600 Subject: [PATCH 10/16] Revert changes to winter:install, ConfigWriter uses ArrayFile internally --- modules/system/console/WinterInstall.php | 97 +++++++++++------------- 1 file changed, 44 insertions(+), 53 deletions(-) diff --git a/modules/system/console/WinterInstall.php b/modules/system/console/WinterInstall.php index 50bc1277d4..dbec0fdbb0 100644 --- a/modules/system/console/WinterInstall.php +++ b/modules/system/console/WinterInstall.php @@ -8,7 +8,7 @@ use Config; use Backend\Database\Seeds\SeedSetupAdmin; use System\Classes\UpdateManager; -use Winter\Storm\Config\ConfigFile; +use Winter\Storm\Config\ConfigWriter; use Illuminate\Console\Command; use Illuminate\Encryption\Encrypter; use Symfony\Component\Console\Input\InputOption; @@ -38,6 +38,11 @@ class WinterInstall extends Command */ protected $description = 'Set up Winter for the first time.'; + /** + * @var Winter\Storm\Config\ConfigWriter + */ + protected $configWriter; + /** * Create a new command instance. */ @@ -45,6 +50,8 @@ public function __construct() { parent::__construct(); + $this->configWriter = new ConfigWriter; + // Register aliases for backwards compatibility with October $this->setAliases(['october:install']); } @@ -113,15 +120,14 @@ protected function getOptions() protected function setupCommonValues() { $url = $this->ask('Application URL', Config::get('app.url')); - $this->getConfigFile('app') - ->set('url', $url) - ->write(); + $this->writeToConfig('app', ['url' => $url]); } protected function setupBackendValues() { // cms.backendUri $backendUri = $this->ask('Backend URL', Config::get('cms.backendUri')); + $this->writeToConfig('cms', ['backendUri' => $backendUri]); // app.locale $defaultLocale = Config::get('app.locale'); @@ -144,10 +150,7 @@ protected function setupBackendValues() // Installation failed halfway through, recover gracefully $locale = $this->ask('Default Backend Locale', $defaultLocale); } - - $this->getConfigFile('app') - ->set('locale', $locale) - ->write(); + $this->writeToConfig('app', ['locale' => $locale]); // cms.backendTimezone $defaultTimezone = Config::get('cms.backendTimezone'); @@ -187,32 +190,21 @@ protected function setupBackendValues() // Installation failed halfway through, recover gracefully $timezone = $this->ask('Default Backend Timezone', $defaultTimezone); } - - $this->getConfigFile('cms') - ->set([ - 'backendTimezone' => $timezone, - 'backendUri' => $backendUri - ]) - ->write(); + $this->writeToConfig('cms', ['backendTimezone' => $timezone]); } protected function setupAdvancedValues() { - $defaultFileMask = $this->ask('File Permission Mask', Config::get('cms.defaultMask.file') ?: '777'); - $defaultDirMask = $this->ask('Folder Permission Mask', Config::get('cms.defaultMask.folder') ?: '777'); - $this->getConfigFile('cms') - ->set([ - 'defaultMask.file' => $defaultFileMask, - 'defaultMask.folder' => $defaultDirMask - ]) - ->write(); - $debug = (bool) $this->confirm('Enable Debug Mode?', true); + $defaultMask = $this->ask('File Permission Mask', Config::get('cms.defaultMask.file') ?: '777'); + $this->writeToConfig('cms', ['defaultMask.file' => $defaultMask]); + + $defaultMask = $this->ask('Folder Permission Mask', Config::get('cms.defaultMask.folder') ?: '777'); + $this->writeToConfig('cms', ['defaultMask.folder' => $defaultMask]); - $this->getConfigFile('app') - ->set('debug', $debug) - ->write(); + $debug = (bool) $this->confirm('Enable Debug Mode?', true); + $this->writeToConfig('app', ['debug' => $debug]); } protected function askToInstallPlugins() @@ -253,9 +245,7 @@ protected function setupEncryptionKey($force = false) } } - $this->getConfigFile('app') - ->set('key', $key) - ->write(); + $this->writeToConfig('app', ['key' => $key]); $this->info(sprintf('Application key [%s] set successfully.', $key)); } @@ -303,15 +293,11 @@ protected function setupDatabaseConfig() $newConfig = $this->$method(); - $settings = ['default' => $driver]; + $this->writeToConfig('database', ['default' => $driver]); foreach ($newConfig as $config => $value) { - $settings['connections.'.$driver.'.'.$config] = $value; + $this->writeToConfig('database', ['connections.'.$driver.'.'.$config => $value]); } - - $this->getConfigFile('database') - ->set($settings) - ->write(); } protected function setupDatabaseMysql() @@ -344,7 +330,7 @@ protected function setupDatabaseSqlite() if (!file_exists($filename)) { $directory = dirname($filename); if (!is_dir($directory)) { - mkdir($directory, 0755, true); + mkdir($directory, 0777, true); } new PDO('sqlite:'.$filename); @@ -450,25 +436,30 @@ protected function displayOutro() $this->line($message); } + protected function writeToConfig($file, $values) + { + $configFile = $this->getConfigFile($file); + + foreach ($values as $key => $value) { + Config::set($file.'.'.$key, $value); + } + + $this->configWriter->toFile($configFile, $values); + } + /** - * Get a config file object. + * Get a config file and contents. * - * @param string $name - * @return ConfigFile + * @return array */ - protected function getConfigFile(string $name): ConfigFile + protected function getConfigFile($name = 'app') { - $file = sprintf( - '%s/%s%s.php', - $this->laravel['path.config'], - $this->option('env') ? $this->option('env') . '/' : '', - $name - ); - - if (!is_dir(dirname($file))) { - mkdir(dirname($file), 0755); - } + $env = $this->option('env') ? $this->option('env').'/' : ''; + + $name .= '.php'; + + $contents = File::get($path = $this->laravel['path.config']."/{$env}{$name}"); - return ConfigFile::read($file, true); + return $path; } -} +} \ No newline at end of file From 8013a57074c7ce16053dca0c2761f719e5d87a7e Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Thu, 3 Mar 2022 18:59:46 -0600 Subject: [PATCH 11/16] Revert "Run default config files through ConfigWriter to minimize changed lines on future uses" This reverts commit 897263e2813596e116ed0b1350e1a9034a646cb0. --- config/app.php | 74 ++++++++++--------- config/auth.php | 56 +++++++-------- config/broadcasting.php | 35 +++++---- config/cache.php | 64 ++++++++++------- config/cms.php | 152 ++++++++++++++++++++-------------------- config/cookie.php | 9 ++- config/database.php | 119 +++++++++++++++++-------------- config/develop.php | 9 +-- config/environment.php | 11 +-- config/filesystems.php | 30 ++++---- config/hashing.php | 17 ++--- config/logging.php | 72 ++++++++++--------- config/mail.php | 40 ++++++----- config/queue.php | 65 +++++++++-------- config/services.php | 13 ++-- config/session.php | 68 +++++++++--------- config/view.php | 20 ++++-- 17 files changed, 469 insertions(+), 385 deletions(-) diff --git a/config/app.php b/config/app.php index 813e09110e..4ba2ad7f91 100644 --- a/config/app.php +++ b/config/app.php @@ -1,7 +1,7 @@ env('APP_DEBUG', true), - + /* |-------------------------------------------------------------------------- | Application Name @@ -28,9 +28,9 @@ | any other location as required by the application or its packages. | */ - + 'name' => env('APP_NAME', 'Winter CMS'), - + /* |-------------------------------------------------------------------------- | Application URL @@ -41,9 +41,9 @@ | your application so that it is used when running Artisan tasks. | */ - + 'url' => env('APP_URL', 'http://localhost'), - + /* |-------------------------------------------------------------------------- | Asset URL @@ -57,9 +57,9 @@ | 'asset_url' => 'https://cdn.example.com/', | */ - + 'asset_url' => env('ASSET_URL', null), - + /* |-------------------------------------------------------------------------- | Trusted hosts @@ -87,9 +87,9 @@ | NOTE: Even when set to `false`, this functionality is explicitly enabled | on the Backend password reset flow for security reasons. */ - + 'trustedHosts' => false, - + /* |-------------------------------------------------------------------------- | Trusted proxies @@ -115,9 +115,9 @@ | 'trustedProxies' => '192.168.1.1, 192.168.1.2' | 'trustedProxies' => ['192.168.1.1', '192.168.1.2'] */ - + 'trustedProxies' => null, - + /* |-------------------------------------------------------------------------- | Trusted proxy headers @@ -150,9 +150,9 @@ | | - Amazon ELB users should always use the "HEADER_X_FORWARDED_AWS_ELB" option. */ - + 'trustedProxyHeaders' => 'HEADER_X_FORWARDED_ALL', - + /* |-------------------------------------------------------------------------- | Application Timezone @@ -171,9 +171,9 @@ | to display dates & times. | */ - + 'timezone' => 'UTC', - + /* |-------------------------------------------------------------------------- | Application Locale Configuration @@ -190,9 +190,9 @@ | Backend\Models\Preference->getLocaleOptions() | */ - + 'locale' => 'en', - + /* |-------------------------------------------------------------------------- | Application Fallback Locale @@ -203,9 +203,9 @@ | the language folders that are provided through your application. | */ - + 'fallback_locale' => 'en', - + /* |-------------------------------------------------------------------------- | Faker Locale @@ -216,9 +216,9 @@ | localized telephone numbers, street address information and more. | */ - + 'faker_locale' => 'en_US', - + /* |-------------------------------------------------------------------------- | Encryption Key @@ -229,10 +229,11 @@ | will not be safe. Please do this before deploying an application! | */ - + 'key' => env('APP_KEY'), + 'cipher' => 'AES-256-CBC', - + /* |-------------------------------------------------------------------------- | Autoloaded Service Providers @@ -243,12 +244,14 @@ | this array to grant expanded functionality to your applications. | */ - - 'providers' => array_merge(include base_path('modules/system/providers.php'), [ + + 'providers' => array_merge(include(base_path('modules/system/providers.php')), [ + // 'Illuminate\Html\HtmlServiceProvider', // Example - 'System\\ServiceProvider', + + 'System\ServiceProvider', ]), - + /* |-------------------------------------------------------------------------- | Load automatically discovered packages @@ -266,9 +269,9 @@ | even if discovery is disabled. | */ - + 'loadDiscoveredPackages' => false, - + /* |-------------------------------------------------------------------------- | Class Aliases @@ -279,6 +282,11 @@ | the aliases are "lazy" loaded so they don't hinder performance. | */ - - 'aliases' => array_merge(include base_path('modules/system/aliases.php'), []), + + 'aliases' => array_merge(include(base_path('modules/system/aliases.php')), [ + + // 'Str' => 'Illuminate\Support\Str', // Example + + ]), + ]; diff --git a/config/auth.php b/config/auth.php index 2acc88e6b4..8dc13b61c7 100644 --- a/config/auth.php +++ b/config/auth.php @@ -1,41 +1,39 @@ [ - /* - |-------------------------------------------------------------------------- - | Enable throttling of Backend authentication attempts - |-------------------------------------------------------------------------- - | - | If set to true, users will be given a limited number of attempts to sign - | in to the Backend before being blocked for a specified number of minutes. - | - */ - + |-------------------------------------------------------------------------- + | Enable throttling of Backend authentication attempts + |-------------------------------------------------------------------------- + | + | If set to true, users will be given a limited number of attempts to sign + | in to the Backend before being blocked for a specified number of minutes. + | + */ 'enabled' => true, - + /* - |-------------------------------------------------------------------------- - | Failed Authentication Attempt Limit - |-------------------------------------------------------------------------- - | - | Number of failed attempts allowed while trying to authenticate a user. - | - */ - + |-------------------------------------------------------------------------- + | Failed Authentication Attempt Limit + |-------------------------------------------------------------------------- + | + | Number of failed attempts allowed while trying to authenticate a user. + | + */ 'attemptLimit' => 5, - + /* - |-------------------------------------------------------------------------- - | Suspension Time - |-------------------------------------------------------------------------- - | - | The number of minutes to suspend further attempts on authentication once - | the attempt limit is reached. - | - */ - + |-------------------------------------------------------------------------- + | Suspension Time + |-------------------------------------------------------------------------- + | + | The number of minutes to suspend further attempts on authentication once + | the attempt limit is reached. + | + */ 'suspensionTime' => 15, ], + ]; diff --git a/config/broadcasting.php b/config/broadcasting.php index 4210685ba4..542f5f1de3 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -1,7 +1,7 @@ env('BROADCAST_DRIVER', 'null'), - + /* |-------------------------------------------------------------------------- | Broadcast Connections @@ -27,32 +27,41 @@ | each available type of connection are provided inside this array. | */ - + 'connections' => [ + 'pusher' => [ - 'app_id' => env('PUSHER_APP_ID'), - 'client_options' => [], - 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY'), - 'options' => [ + 'app_id' => env('PUSHER_APP_ID'), + 'client_options' => [ + // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html + ], + 'driver' => 'pusher', + 'key' => env('PUSHER_APP_KEY'), + 'options' => [ 'cluster' => env('PUSHER_APP_CLUSTER'), - 'useTLS' => true, + 'useTLS' => true, ], - 'secret' => env('PUSHER_APP_SECRET'), + 'secret' => env('PUSHER_APP_SECRET'), ], + 'ably' => [ 'driver' => 'ably', - 'key' => env('ABLY_KEY'), + 'key' => env('ABLY_KEY'), ], + 'redis' => [ 'connection' => 'default', - 'driver' => 'redis', + 'driver' => 'redis', ], + 'log' => [ 'driver' => 'log', ], + 'null' => [ 'driver' => 'null', ], + ], + ]; diff --git a/config/cache.php b/config/cache.php index 22597b4cd3..e2bba31603 100644 --- a/config/cache.php +++ b/config/cache.php @@ -1,7 +1,7 @@ env('CACHE_DRIVER', 'file'), - + /* |-------------------------------------------------------------------------- | Cache Stores @@ -33,34 +33,41 @@ | "memcached", "redis", "dynamodb", "octane", "null" | */ - + 'stores' => [ + 'apc' => [ 'driver' => 'apc', ], + 'array' => [ - 'driver' => 'array', + 'driver' => 'array', 'serialize' => false, ], + 'database' => [ - 'connection' => null, - 'driver' => 'database', + 'connection' => null, + 'driver' => 'database', 'lock_connection' => null, - 'table' => 'cache', + 'table' => 'cache', ], + 'file' => [ 'driver' => 'file', - 'path' => storage_path('framework/cache'), + 'path' => storage_path('framework/cache'), ], + 'memcached' => [ - 'driver' => 'memcached', - 'options' => [], + 'driver' => 'memcached', + 'options' => [ + // Memcached::OPT_CONNECT_TIMEOUT => 2000, + ], 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 'sasl' => [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], - 'servers' => [ + 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 'port' => env('MEMCACHED_PORT', 11211), @@ -68,24 +75,28 @@ ], ], ], + 'redis' => [ - 'connection' => 'cache', - 'driver' => 'redis', + 'connection' => 'cache', + 'driver' => 'redis', 'lock_connection' => 'default', ], + 'dynamodb' => [ - 'driver' => 'dynamodb', + 'driver' => 'dynamodb', 'endpoint' => env('DYNAMODB_ENDPOINT'), - 'key' => env('AWS_ACCESS_KEY_ID'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), ], + 'octane' => [ 'driver' => 'octane', ], + ], - + /* |-------------------------------------------------------------------------- | Cache Key Prefix @@ -96,9 +107,9 @@ | value to get prefixed to all our keys so we can avoid collisions. | */ - - 'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'winter'), '_') . '_cache'), - + + 'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'winter'), '_').'_cache'), + /* |-------------------------------------------------------------------------- | Cache Key for the CMS' PHP code parser cache @@ -110,9 +121,9 @@ | prevent conflicts. | */ - + 'codeParserDataCacheKey' => 'cms-php-file-data', - + /* |-------------------------------------------------------------------------- | Disable Request Cache @@ -132,6 +143,7 @@ | null - enable for HTTP requests, disable when running in CLI | */ - + 'disableRequestCache' => null, + ]; diff --git a/config/cms.php b/config/cms.php index 483d13fdfa..4da7fd4a7e 100644 --- a/config/cms.php +++ b/config/cms.php @@ -1,7 +1,7 @@ 'demo', - + /* |-------------------------------------------------------------------------- | Bleeding edge updates @@ -23,9 +23,9 @@ | and use the development copies of core files and plugins. | */ - + 'edgeUpdates' => false, - + /* |-------------------------------------------------------------------------- | Back-end URI prefix @@ -35,9 +35,9 @@ | For example: backend -> http://localhost/backend | */ - + 'backendUri' => 'backend', - + /* |-------------------------------------------------------------------------- | Back-end force HTTPS security @@ -48,9 +48,9 @@ | web server config, but can be handled by the app for added security. | */ - + 'backendForceSecure' => false, - + /* |-------------------------------------------------------------------------- | Back-end login remember @@ -66,9 +66,9 @@ | wanted behavior | */ - + 'backendForceRemember' => true, - + /* |-------------------------------------------------------------------------- | Back-end timezone @@ -79,9 +79,9 @@ | dates displayed in the back-end will be converted to this timezone. | */ - + 'backendTimezone' => 'UTC', - + /* |-------------------------------------------------------------------------- | Back-end Skin @@ -90,9 +90,9 @@ | Specifies the back-end skin to use. | */ - - 'backendSkin' => 'Backend\\Skins\\Standard', - + + 'backendSkin' => 'Backend\Skins\Standard', + /* |-------------------------------------------------------------------------- | Automatically run migrations on login @@ -105,9 +105,9 @@ | and disabled when debug mode is disabled. | */ - + 'runMigrationsOnLogin' => null, - + /* |-------------------------------------------------------------------------- | Determines which modules to load @@ -116,13 +116,9 @@ | Specify which modules should be registered when using the application. | */ - - 'loadModules' => [ - 'System', - 'Backend', - 'Cms', - ], - + + 'loadModules' => ['System', 'Backend', 'Cms'], + /* |-------------------------------------------------------------------------- | Prevents application updates @@ -134,9 +130,9 @@ | and themes will still be downloaded. | */ - + 'disableCoreUpdates' => false, - + /* |-------------------------------------------------------------------------- | Specific plugins to disable @@ -145,9 +141,9 @@ | Specify plugin codes which will always be disabled in the application. | */ - + 'disablePlugins' => [], - + /* |-------------------------------------------------------------------------- | Determines if the routing caching is enabled. @@ -159,9 +155,9 @@ | to disable the caching during the development, and enable it in the production mode. | */ - + 'enableRoutesCache' => false, - + /* |-------------------------------------------------------------------------- | Time to live for the URL map. @@ -172,9 +168,9 @@ | interval, in minutes, specified with the urlMapCacheTTL parameter expires. | */ - + 'urlCacheTtl' => 10, - + /* |-------------------------------------------------------------------------- | Time to live for parsed CMS objects. @@ -185,9 +181,9 @@ | the corresponding template file is modified. | */ - + 'parsedPageCacheTTL' => 10, - + /* |-------------------------------------------------------------------------- | Determines if the asset caching is enabled. @@ -199,9 +195,9 @@ | to disable the caching during the development, and enable it in the production mode. | */ - + 'enableAssetCache' => false, - + /* |-------------------------------------------------------------------------- | Determines if the asset minification is enabled. @@ -213,9 +209,9 @@ | when debug mode (app.debug) is disabled. | */ - + 'enableAssetMinify' => null, - + /* |-------------------------------------------------------------------------- | Check import timestamps when combining assets @@ -227,9 +223,9 @@ | is used when debug mode (app.debug) is enabled. | */ - + 'enableAssetDeepHashing' => null, - + /* |-------------------------------------------------------------------------- | Database-driven Themes @@ -253,9 +249,9 @@ | from the database. | */ - + 'databaseTemplates' => false, - + /* |-------------------------------------------------------------------------- | Public plugins path @@ -265,9 +261,9 @@ | or you can specify a full URL path. | */ - + 'pluginsPath' => '/plugins', - + /* |-------------------------------------------------------------------------- | Public themes path @@ -277,9 +273,9 @@ | or you can specify a full URL path. | */ - + 'themesPath' => '/themes', - + /* |-------------------------------------------------------------------------- | Resource storage @@ -314,26 +310,30 @@ | path for the uploads disk and `/projects/winter/storage/app/media` as | the path for the media disk. */ - + 'storage' => [ + 'uploads' => [ - 'disk' => 'local', - 'folder' => 'uploads', - 'path' => '/storage/app/uploads', + 'disk' => 'local', + 'folder' => 'uploads', + 'path' => '/storage/app/uploads', 'temporaryUrlTTL' => 3600, ], + 'media' => [ - 'disk' => 'local', + 'disk' => 'local', 'folder' => 'media', - 'path' => '/storage/app/media', + 'path' => '/storage/app/media', ], + 'resized' => [ - 'disk' => 'local', + 'disk' => 'local', 'folder' => 'resized', - 'path' => '/storage/app/resized', + 'path' => '/storage/app/resized', ], + ], - + /* |-------------------------------------------------------------------------- | Convert Line Endings @@ -343,9 +343,9 @@ | \r\n to the unix style \n. | */ - + 'convertLineEndings' => false, - + /* |-------------------------------------------------------------------------- | Linking policy @@ -359,9 +359,9 @@ | force - force hostname and schema using app.url config value | */ - + 'linkPolicy' => 'detect', - + /* |-------------------------------------------------------------------------- | Default permission mask @@ -370,12 +370,9 @@ | Specifies a default file and folder permission for newly created objects. | */ - - 'defaultMask' => [ - 'file' => null, - 'folder' => null, - ], - + + 'defaultMask' => ['file' => null, 'folder' => null], + /* |-------------------------------------------------------------------------- | Safe mode @@ -386,9 +383,9 @@ | debug mode (app.debug) is disabled. | */ - + 'enableSafeMode' => null, - + /* |-------------------------------------------------------------------------- | Cross Site Request Forgery (CSRF) Protection @@ -398,9 +395,9 @@ | checked for a valid security token. | */ - + 'enableCsrfProtection' => true, - + /* |-------------------------------------------------------------------------- | Force bytecode invalidation @@ -411,9 +408,9 @@ | cache won't update the cache, set to true to get around this. | */ - + 'forceBytecodeInvalidation' => true, - + /* |-------------------------------------------------------------------------- | Twig Strict Variables @@ -426,9 +423,9 @@ | enabled. | */ - + 'enableTwigStrictVariables' => false, - + /* |-------------------------------------------------------------------------- | Base Directory Restriction @@ -445,9 +442,9 @@ | NEVER have this disabled in production. | */ - + 'restrictBaseDir' => true, - + /* |-------------------------------------------------------------------------- | Backend Service Worker @@ -467,6 +464,7 @@ | false - disallow service workers to run in the backend | */ - + 'enableBackendServiceWorkers' => false, + ]; diff --git a/config/cookie.php b/config/cookie.php index a6c8528d76..f286fe5a6b 100644 --- a/config/cookie.php +++ b/config/cookie.php @@ -1,7 +1,7 @@ [], + + 'unencryptedCookies' => [ + // 'my_cookie', + ], + ]; diff --git a/config/database.php b/config/database.php index 5d4bd6c398..2d612ab1ce 100644 --- a/config/database.php +++ b/config/database.php @@ -1,7 +1,7 @@ env('DB_CONNECTION', 'mysql'), - + /* |-------------------------------------------------------------------------- | Database Connections @@ -29,63 +29,68 @@ | choice installed on your machine before you begin development. | */ - + 'connections' => [ + 'sqlite' => [ - 'database' => env('DB_DATABASE', storage_path('database.sqlite')), - 'driver' => 'sqlite', + 'database' => env('DB_DATABASE', storage_path('database.sqlite')), + 'driver' => 'sqlite', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), - 'prefix' => '', - 'url' => env('DATABASE_URL'), + 'prefix' => '', + 'url' => env('DATABASE_URL'), ], + 'mysql' => [ - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'mysql', - 'engine' => 'InnoDB', - 'host' => env('DB_HOST', '127.0.0.1'), - 'options' => extension_loaded('pdo_mysql') ? array_filter([ + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'mysql', + 'engine' => 'InnoDB', + 'host' => env('DB_HOST', '127.0.0.1'), + 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '3306'), - 'prefix' => '', + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '3306'), + 'prefix' => '', 'prefix_indexes' => true, - 'strict' => true, - 'unix_socket' => env('DB_SOCKET', ''), - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), - 'varcharmax' => 191, + 'strict' => true, + 'unix_socket' => env('DB_SOCKET', ''), + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), + 'varcharmax' => 191, ], + 'pgsql' => [ - 'charset' => 'utf8', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'pgsql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '5432'), - 'prefix' => '', + 'charset' => 'utf8', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'pgsql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '5432'), + 'prefix' => '', 'prefix_indexes' => true, - 'search_path' => 'public', - 'sslmode' => 'prefer', - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), + 'search_path' => 'public', + 'sslmode' => 'prefer', + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), ], + 'sqlsrv' => [ - 'charset' => 'utf8', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'sqlsrv', - 'host' => env('DB_HOST', '127.0.0.1'), - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '1433'), - 'prefix' => '', + 'charset' => 'utf8', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'sqlsrv', + 'host' => env('DB_HOST', '127.0.0.1'), + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '1433'), + 'prefix' => '', 'prefix_indexes' => true, - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), ], + ], - + /* |-------------------------------------------------------------------------- | Migration Repository Table @@ -96,9 +101,9 @@ | the migrations on disk haven't actually been run in the database. | */ - + 'migrations' => 'migrations', - + /* |-------------------------------------------------------------------------- | Redis Databases @@ -109,26 +114,32 @@ | such as APC or Memcached. Winter makes it easy to dig right in. | */ - + 'redis' => [ + 'client' => env('REDIS_CLIENT', 'phpredis'), + 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', str_slug(env('APP_NAME', 'winter'), '_') . '_database_'), + 'prefix' => env('REDIS_PREFIX', str_slug(env('APP_NAME', 'winter'), '_').'_database_'), ], + 'default' => [ 'database' => env('REDIS_DB', '0'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'url' => env('REDIS_URL'), + 'port' => env('REDIS_PORT', '6379'), + 'url' => env('REDIS_URL'), ], + 'cache' => [ 'database' => env('REDIS_CACHE_DB', '1'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'url' => env('REDIS_URL'), + 'port' => env('REDIS_PORT', '6379'), + 'url' => env('REDIS_URL'), ], + ], + ]; diff --git a/config/develop.php b/config/develop.php index 47c89175c8..381b56409d 100644 --- a/config/develop.php +++ b/config/develop.php @@ -1,7 +1,7 @@ false, - + /* |-------------------------------------------------------------------------- | Allow deep-level symlinks @@ -40,6 +40,7 @@ | false - only allow symlinks at the first level of subdirectories (default) | */ - + 'allowDeepSymlinks' => false, + ]; diff --git a/config/environment.php b/config/environment.php index fb17f634df..5249b15bad 100644 --- a/config/environment.php +++ b/config/environment.php @@ -1,7 +1,7 @@ 'development', - + /* |-------------------------------------------------------------------------- | Environment Multitenancy @@ -25,8 +25,11 @@ | different configuration, such as database and theme, per hostname. | */ - + 'hosts' => [ + 'localhost' => 'dev', + ], + ]; diff --git a/config/filesystems.php b/config/filesystems.php index 0fc1103700..a85fcc8a9e 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -1,7 +1,7 @@ env('FILESYSTEM_DISK', 'local'), - + /* |-------------------------------------------------------------------------- | Filesystem Disks @@ -27,22 +27,26 @@ | Supported Drivers: "local", "ftp", "sftp", "s3" | */ - + 'disks' => [ + 'local' => [ 'driver' => 'local', - 'root' => storage_path('app'), - 'url' => '/storage/app', + 'root' => storage_path('app'), + 'url' => '/storage/app', ], + 's3' => [ - 'bucket' => env('AWS_BUCKET'), - 'driver' => 's3', - 'endpoint' => env('AWS_ENDPOINT'), - 'key' => env('AWS_ACCESS_KEY_ID'), - 'region' => env('AWS_DEFAULT_REGION'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'url' => env('AWS_URL'), + 'bucket' => env('AWS_BUCKET'), + 'driver' => 's3', + 'endpoint' => env('AWS_ENDPOINT'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'region' => env('AWS_DEFAULT_REGION'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'url' => env('AWS_URL'), 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), ], + ], + ]; diff --git a/config/hashing.php b/config/hashing.php index f8c867896a..616059443b 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -1,7 +1,7 @@ 'bcrypt', - + /* |-------------------------------------------------------------------------- | Bcrypt Options @@ -27,11 +27,11 @@ | to control the amount of time it takes to hash the given password. | */ - + 'bcrypt' => [ 'rounds' => env('BCRYPT_ROUNDS', 10), ], - + /* |-------------------------------------------------------------------------- | Argon Options @@ -42,10 +42,11 @@ | to control the amount of time it takes to hash the given password. | */ - + 'argon' => [ - 'memory' => 65536, + 'memory' => 65536, 'threads' => 1, - 'time' => 4, + 'time' => 4, ], + ]; diff --git a/config/logging.php b/config/logging.php index e60a3fa51f..e7ea8f3bb6 100644 --- a/config/logging.php +++ b/config/logging.php @@ -1,7 +1,7 @@ env('LOG_CHANNEL', 'stack'), - + /* |-------------------------------------------------------------------------- | Deprecations Log Channel @@ -25,9 +25,9 @@ | your application ready for upcoming major versions of dependencies. | */ - + 'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), - + /* |-------------------------------------------------------------------------- | Log Channels @@ -42,66 +42,74 @@ | "custom", "stack" | */ - + 'channels' => [ 'stack' => [ - 'channels' => [ - 'single', - ], - 'driver' => 'stack', + 'channels' => ['single'], + 'driver' => 'stack', 'ignore_exceptions' => false, ], + 'single' => [ 'driver' => 'single', - 'level' => env('LOG_LEVEL', 'debug'), - 'path' => storage_path('logs/system.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'path' => storage_path('logs/system.log'), ], + 'daily' => [ - 'days' => 14, + 'days' => 14, 'driver' => 'daily', - 'level' => env('LOG_LEVEL', 'debug'), - 'path' => storage_path('logs/system.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'path' => storage_path('logs/system.log'), ], + 'slack' => [ - 'driver' => 'slack', - 'emoji' => ':boom:', - 'level' => env('LOG_LEVEL', 'critical'), - 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'driver' => 'slack', + 'emoji' => ':boom:', + 'level' => env('LOG_LEVEL', 'critical'), + 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Winter Log', ], + 'papertrail' => [ - 'driver' => 'monolog', - 'handler' => env('LOG_PAPERTRAIL_HANDLER', \Monolog\Handler\SyslogUdpHandler::class), + 'driver' => 'monolog', + 'handler' => env('LOG_PAPERTRAIL_HANDLER', \Monolog\Handler\SyslogUdpHandler::class), 'handler_with' => [ - 'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'), - 'host' => env('PAPERTRAIL_URL'), - 'port' => env('PAPERTRAIL_PORT'), + 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), + 'host' => env('PAPERTRAIL_URL'), + 'port' => env('PAPERTRAIL_PORT'), ], - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], + 'stderr' => [ - 'driver' => 'monolog', + 'driver' => 'monolog', 'formatter' => env('LOG_STDERR_FORMATTER'), - 'handler' => \Monolog\Handler\StreamHandler::class, - 'level' => env('LOG_LEVEL', 'debug'), - 'with' => [ + 'handler' => \Monolog\Handler\StreamHandler::class, + 'level' => env('LOG_LEVEL', 'debug'), + 'with' => [ 'stream' => 'php://stderr', ], ], + 'syslog' => [ 'driver' => 'syslog', - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], + 'errorlog' => [ 'driver' => 'errorlog', - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], + 'null' => [ - 'driver' => 'monolog', + 'driver' => 'monolog', 'handler' => \Monolog\Handler\NullHandler::class, ], + 'emergency' => [ 'path' => storage_path('logs/system.log'), ], ], + ]; diff --git a/config/mail.php b/config/mail.php index d1c10db337..25a896d141 100644 --- a/config/mail.php +++ b/config/mail.php @@ -1,7 +1,7 @@ env('MAIL_MAILER', 'smtp'), - + /* |-------------------------------------------------------------------------- | Mailer Configurations @@ -32,46 +32,53 @@ | "postmark", "log", "array", "failover" | */ - + 'mailers' => [ 'smtp' => [ 'encryption' => env('MAIL_ENCRYPTION', 'tls'), - 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), - 'password' => env('MAIL_PASSWORD'), - 'port' => env('MAIL_PORT', 587), - 'timeout' => null, - 'transport' => 'smtp', - 'username' => env('MAIL_USERNAME'), + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), + 'password' => env('MAIL_PASSWORD'), + 'port' => env('MAIL_PORT', 587), + 'timeout' => null, + 'transport' => 'smtp', + 'username' => env('MAIL_USERNAME'), ], + 'ses' => [ 'transport' => 'ses', ], + 'mailgun' => [ 'transport' => 'mailgun', ], + 'postmark' => [ 'transport' => 'postmark', ], + 'sendmail' => [ - 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), + 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), 'transport' => 'sendmail', ], + 'log' => [ - 'channel' => env('MAIL_LOG_CHANNEL'), + 'channel' => env('MAIL_LOG_CHANNEL'), 'transport' => 'log', ], + 'array' => [ 'transport' => 'array', ], + 'failover' => [ - 'mailers' => [ + 'mailers' => [ 'smtp', 'log', ], 'transport' => 'failover', ], ], - + /* |-------------------------------------------------------------------------- | Global "From" Address @@ -82,9 +89,10 @@ | used globally for all e-mails that are sent by your application. | */ - + 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'noreply@example.com'), - 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Winter CMS')), + 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Winter CMS')), ], + ]; diff --git a/config/queue.php b/config/queue.php index 569d9ee426..ba40614d70 100644 --- a/config/queue.php +++ b/config/queue.php @@ -1,7 +1,7 @@ env('QUEUE_CONNECTION', 'sync'), - + /* |-------------------------------------------------------------------------- | Queue Connections @@ -27,46 +27,52 @@ | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" | */ - + 'connections' => [ + 'sync' => [ 'driver' => 'sync', ], + 'database' => [ 'after_commit' => false, - 'driver' => 'database', - 'queue' => 'default', - 'retry_after' => 90, - 'table' => 'jobs', + 'driver' => 'database', + 'queue' => 'default', + 'retry_after' => 90, + 'table' => 'jobs', ], + 'beanstalkd' => [ 'after_commit' => false, - 'block_for' => 0, - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, + 'block_for' => 0, + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'retry_after' => 90, ], + 'sqs' => [ 'after_commit' => false, - 'driver' => 'sqs', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), - 'queue' => env('SQS_QUEUE', 'default'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'suffix' => env('SQS_SUFFIX'), + 'driver' => 'sqs', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'default'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'suffix' => env('SQS_SUFFIX'), ], + 'redis' => [ 'after_commit' => false, - 'block_for' => null, - 'connection' => 'default', - 'driver' => 'redis', - 'queue' => env('REDIS_QUEUE', 'default'), - 'retry_after' => 90, + 'block_for' => null, + 'connection' => 'default', + 'driver' => 'redis', + 'queue' => env('REDIS_QUEUE', 'default'), + 'retry_after' => 90, ], + ], - + /* |-------------------------------------------------------------------------- | Failed Queue Jobs @@ -77,10 +83,11 @@ | have failed. You may change them to any database / table you wish. | */ - + 'failed' => [ 'database' => env('DB_CONNECTION', 'mysql'), - 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), - 'table' => 'failed_jobs', + 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), + 'table' => 'failed_jobs', ], + ]; diff --git a/config/services.php b/config/services.php index d2cf8694bb..32760c1d49 100644 --- a/config/services.php +++ b/config/services.php @@ -1,7 +1,7 @@ [ - 'domain' => env('MAILGUN_DOMAIN'), + 'domain' => env('MAILGUN_DOMAIN'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), - 'secret' => env('MAILGUN_SECRET'), + 'secret' => env('MAILGUN_SECRET'), ], + 'postmark' => [ 'token' => env('POSTMARK_TOKEN'), ], + 'ses' => [ - 'key' => env('AWS_ACCESS_KEY_ID'), + 'key' => env('AWS_ACCESS_KEY_ID'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), ], + ]; diff --git a/config/session.php b/config/session.php index 73b725aaf9..78aac1472e 100644 --- a/config/session.php +++ b/config/session.php @@ -1,7 +1,7 @@ env('SESSION_DRIVER', 'file'), - + /* |-------------------------------------------------------------------------- | Session Lifetime @@ -28,10 +28,11 @@ | to immediately expire on the browser closing, set that option. | */ - + 'lifetime' => env('SESSION_LIFETIME', 120), + 'expire_on_close' => false, - + /* |-------------------------------------------------------------------------- | Session Encryption @@ -42,9 +43,9 @@ | automatically by Laravel and you can use the Session like normal. | */ - + 'encrypt' => false, - + /* |-------------------------------------------------------------------------- | Session File Location @@ -55,9 +56,9 @@ | location may be specified. This is only needed for file sessions. | */ - + 'files' => storage_path('framework/sessions'), - + /* |-------------------------------------------------------------------------- | Session Database Connection @@ -68,9 +69,9 @@ | correspond to a connection in your database configuration options. | */ - + 'connection' => env('SESSION_CONNECTION'), - + /* |-------------------------------------------------------------------------- | Session Database Table @@ -81,9 +82,9 @@ | provided for you; however, you are free to change this as needed. | */ - + 'table' => 'sessions', - + /* |-------------------------------------------------------------------------- | Session Cache Store @@ -96,9 +97,9 @@ | Affects: "apc", "dynamodb", "memcached", "redis" | */ - + 'store' => env('SESSION_STORE'), - + /* |-------------------------------------------------------------------------- | Session Sweeping Lottery @@ -109,12 +110,9 @@ | happen on a given request. By default, the odds are 2 out of 100. | */ - - 'lottery' => [ - 2, - 100, - ], - + + 'lottery' => [2, 100], + /* |-------------------------------------------------------------------------- | Session Cookie Name @@ -125,9 +123,12 @@ | new session cookie is created by the framework for every driver. | */ - - 'cookie' => env('SESSION_COOKIE', str_slug(env('APP_NAME', 'winter'), '_') . '_session'), - + + 'cookie' => env( + 'SESSION_COOKIE', + str_slug(env('APP_NAME', 'winter'), '_').'_session' + ), + /* |-------------------------------------------------------------------------- | Session Cookie Path @@ -138,9 +139,9 @@ | your application but you are free to change this when necessary. | */ - + 'path' => '/', - + /* |-------------------------------------------------------------------------- | Session Cookie Domain @@ -151,9 +152,9 @@ | available to in your application. A sensible default has been set. | */ - + 'domain' => env('SESSION_DOMAIN'), - + /* |-------------------------------------------------------------------------- | HTTP Access Only @@ -164,9 +165,9 @@ | the HTTP protocol. You are free to modify this option if needed. | */ - + 'http_only' => true, - + /* |-------------------------------------------------------------------------- | HTTPS Only Cookies @@ -177,9 +178,9 @@ | the cookie from being sent to you when it can't be done securely. | */ - + 'secure' => env('SESSION_SECURE_COOKIE', false), - + /* |-------------------------------------------------------------------------- | Same-Site Cookies @@ -211,6 +212,7 @@ | Supported: "lax", "strict", "none", null | */ - + 'same_site' => 'lax', + ]; diff --git a/config/view.php b/config/view.php index e38f47fd31..bbbb7327e0 100644 --- a/config/view.php +++ b/config/view.php @@ -1,7 +1,7 @@ [], - + + 'paths' => [ + // Default Laravel Blade template location + // @see https://github.com/octobercms/october/issues/3473 & https://github.com/octobercms/october/issues/3459 + // realpath(base_path('resources/views')) + ], + /* |-------------------------------------------------------------------------- | Compiled View Path @@ -25,6 +29,10 @@ | directory. However, as usual, you are free to change this value. | */ - - 'compiled' => env('VIEW_COMPILED_PATH', realpath(storage_path('framework/views'))), + + 'compiled' => env( + 'VIEW_COMPILED_PATH', + realpath(storage_path('framework/views')) + ), + ]; From 70cfd902bd2d23bb5321ae57556a94cb93102e42 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Tue, 15 Mar 2022 21:05:08 -0600 Subject: [PATCH 12/16] Revert "Run the default config through ArrayFile parser" This reverts commit c3bdfae664c1cdde2ea1403027fc38b0822a0cf5. --- config/app.php | 74 ++++++++++--------- config/auth.php | 56 +++++++-------- config/broadcasting.php | 35 +++++---- config/cache.php | 64 ++++++++++------- config/cms.php | 152 ++++++++++++++++++++-------------------- config/cookie.php | 9 ++- config/database.php | 119 +++++++++++++++++-------------- config/develop.php | 9 +-- config/environment.php | 11 +-- config/filesystems.php | 30 ++++---- config/hashing.php | 17 ++--- config/logging.php | 72 ++++++++++--------- config/mail.php | 40 ++++++----- config/queue.php | 65 +++++++++-------- config/services.php | 13 ++-- config/session.php | 68 +++++++++--------- config/view.php | 20 ++++-- 17 files changed, 469 insertions(+), 385 deletions(-) diff --git a/config/app.php b/config/app.php index 813e09110e..4ba2ad7f91 100644 --- a/config/app.php +++ b/config/app.php @@ -1,7 +1,7 @@ env('APP_DEBUG', true), - + /* |-------------------------------------------------------------------------- | Application Name @@ -28,9 +28,9 @@ | any other location as required by the application or its packages. | */ - + 'name' => env('APP_NAME', 'Winter CMS'), - + /* |-------------------------------------------------------------------------- | Application URL @@ -41,9 +41,9 @@ | your application so that it is used when running Artisan tasks. | */ - + 'url' => env('APP_URL', 'http://localhost'), - + /* |-------------------------------------------------------------------------- | Asset URL @@ -57,9 +57,9 @@ | 'asset_url' => 'https://cdn.example.com/', | */ - + 'asset_url' => env('ASSET_URL', null), - + /* |-------------------------------------------------------------------------- | Trusted hosts @@ -87,9 +87,9 @@ | NOTE: Even when set to `false`, this functionality is explicitly enabled | on the Backend password reset flow for security reasons. */ - + 'trustedHosts' => false, - + /* |-------------------------------------------------------------------------- | Trusted proxies @@ -115,9 +115,9 @@ | 'trustedProxies' => '192.168.1.1, 192.168.1.2' | 'trustedProxies' => ['192.168.1.1', '192.168.1.2'] */ - + 'trustedProxies' => null, - + /* |-------------------------------------------------------------------------- | Trusted proxy headers @@ -150,9 +150,9 @@ | | - Amazon ELB users should always use the "HEADER_X_FORWARDED_AWS_ELB" option. */ - + 'trustedProxyHeaders' => 'HEADER_X_FORWARDED_ALL', - + /* |-------------------------------------------------------------------------- | Application Timezone @@ -171,9 +171,9 @@ | to display dates & times. | */ - + 'timezone' => 'UTC', - + /* |-------------------------------------------------------------------------- | Application Locale Configuration @@ -190,9 +190,9 @@ | Backend\Models\Preference->getLocaleOptions() | */ - + 'locale' => 'en', - + /* |-------------------------------------------------------------------------- | Application Fallback Locale @@ -203,9 +203,9 @@ | the language folders that are provided through your application. | */ - + 'fallback_locale' => 'en', - + /* |-------------------------------------------------------------------------- | Faker Locale @@ -216,9 +216,9 @@ | localized telephone numbers, street address information and more. | */ - + 'faker_locale' => 'en_US', - + /* |-------------------------------------------------------------------------- | Encryption Key @@ -229,10 +229,11 @@ | will not be safe. Please do this before deploying an application! | */ - + 'key' => env('APP_KEY'), + 'cipher' => 'AES-256-CBC', - + /* |-------------------------------------------------------------------------- | Autoloaded Service Providers @@ -243,12 +244,14 @@ | this array to grant expanded functionality to your applications. | */ - - 'providers' => array_merge(include base_path('modules/system/providers.php'), [ + + 'providers' => array_merge(include(base_path('modules/system/providers.php')), [ + // 'Illuminate\Html\HtmlServiceProvider', // Example - 'System\\ServiceProvider', + + 'System\ServiceProvider', ]), - + /* |-------------------------------------------------------------------------- | Load automatically discovered packages @@ -266,9 +269,9 @@ | even if discovery is disabled. | */ - + 'loadDiscoveredPackages' => false, - + /* |-------------------------------------------------------------------------- | Class Aliases @@ -279,6 +282,11 @@ | the aliases are "lazy" loaded so they don't hinder performance. | */ - - 'aliases' => array_merge(include base_path('modules/system/aliases.php'), []), + + 'aliases' => array_merge(include(base_path('modules/system/aliases.php')), [ + + // 'Str' => 'Illuminate\Support\Str', // Example + + ]), + ]; diff --git a/config/auth.php b/config/auth.php index 2acc88e6b4..8dc13b61c7 100644 --- a/config/auth.php +++ b/config/auth.php @@ -1,41 +1,39 @@ [ - /* - |-------------------------------------------------------------------------- - | Enable throttling of Backend authentication attempts - |-------------------------------------------------------------------------- - | - | If set to true, users will be given a limited number of attempts to sign - | in to the Backend before being blocked for a specified number of minutes. - | - */ - + |-------------------------------------------------------------------------- + | Enable throttling of Backend authentication attempts + |-------------------------------------------------------------------------- + | + | If set to true, users will be given a limited number of attempts to sign + | in to the Backend before being blocked for a specified number of minutes. + | + */ 'enabled' => true, - + /* - |-------------------------------------------------------------------------- - | Failed Authentication Attempt Limit - |-------------------------------------------------------------------------- - | - | Number of failed attempts allowed while trying to authenticate a user. - | - */ - + |-------------------------------------------------------------------------- + | Failed Authentication Attempt Limit + |-------------------------------------------------------------------------- + | + | Number of failed attempts allowed while trying to authenticate a user. + | + */ 'attemptLimit' => 5, - + /* - |-------------------------------------------------------------------------- - | Suspension Time - |-------------------------------------------------------------------------- - | - | The number of minutes to suspend further attempts on authentication once - | the attempt limit is reached. - | - */ - + |-------------------------------------------------------------------------- + | Suspension Time + |-------------------------------------------------------------------------- + | + | The number of minutes to suspend further attempts on authentication once + | the attempt limit is reached. + | + */ 'suspensionTime' => 15, ], + ]; diff --git a/config/broadcasting.php b/config/broadcasting.php index 4210685ba4..542f5f1de3 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -1,7 +1,7 @@ env('BROADCAST_DRIVER', 'null'), - + /* |-------------------------------------------------------------------------- | Broadcast Connections @@ -27,32 +27,41 @@ | each available type of connection are provided inside this array. | */ - + 'connections' => [ + 'pusher' => [ - 'app_id' => env('PUSHER_APP_ID'), - 'client_options' => [], - 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY'), - 'options' => [ + 'app_id' => env('PUSHER_APP_ID'), + 'client_options' => [ + // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html + ], + 'driver' => 'pusher', + 'key' => env('PUSHER_APP_KEY'), + 'options' => [ 'cluster' => env('PUSHER_APP_CLUSTER'), - 'useTLS' => true, + 'useTLS' => true, ], - 'secret' => env('PUSHER_APP_SECRET'), + 'secret' => env('PUSHER_APP_SECRET'), ], + 'ably' => [ 'driver' => 'ably', - 'key' => env('ABLY_KEY'), + 'key' => env('ABLY_KEY'), ], + 'redis' => [ 'connection' => 'default', - 'driver' => 'redis', + 'driver' => 'redis', ], + 'log' => [ 'driver' => 'log', ], + 'null' => [ 'driver' => 'null', ], + ], + ]; diff --git a/config/cache.php b/config/cache.php index 22597b4cd3..e2bba31603 100644 --- a/config/cache.php +++ b/config/cache.php @@ -1,7 +1,7 @@ env('CACHE_DRIVER', 'file'), - + /* |-------------------------------------------------------------------------- | Cache Stores @@ -33,34 +33,41 @@ | "memcached", "redis", "dynamodb", "octane", "null" | */ - + 'stores' => [ + 'apc' => [ 'driver' => 'apc', ], + 'array' => [ - 'driver' => 'array', + 'driver' => 'array', 'serialize' => false, ], + 'database' => [ - 'connection' => null, - 'driver' => 'database', + 'connection' => null, + 'driver' => 'database', 'lock_connection' => null, - 'table' => 'cache', + 'table' => 'cache', ], + 'file' => [ 'driver' => 'file', - 'path' => storage_path('framework/cache'), + 'path' => storage_path('framework/cache'), ], + 'memcached' => [ - 'driver' => 'memcached', - 'options' => [], + 'driver' => 'memcached', + 'options' => [ + // Memcached::OPT_CONNECT_TIMEOUT => 2000, + ], 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 'sasl' => [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], - 'servers' => [ + 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 'port' => env('MEMCACHED_PORT', 11211), @@ -68,24 +75,28 @@ ], ], ], + 'redis' => [ - 'connection' => 'cache', - 'driver' => 'redis', + 'connection' => 'cache', + 'driver' => 'redis', 'lock_connection' => 'default', ], + 'dynamodb' => [ - 'driver' => 'dynamodb', + 'driver' => 'dynamodb', 'endpoint' => env('DYNAMODB_ENDPOINT'), - 'key' => env('AWS_ACCESS_KEY_ID'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), ], + 'octane' => [ 'driver' => 'octane', ], + ], - + /* |-------------------------------------------------------------------------- | Cache Key Prefix @@ -96,9 +107,9 @@ | value to get prefixed to all our keys so we can avoid collisions. | */ - - 'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'winter'), '_') . '_cache'), - + + 'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'winter'), '_').'_cache'), + /* |-------------------------------------------------------------------------- | Cache Key for the CMS' PHP code parser cache @@ -110,9 +121,9 @@ | prevent conflicts. | */ - + 'codeParserDataCacheKey' => 'cms-php-file-data', - + /* |-------------------------------------------------------------------------- | Disable Request Cache @@ -132,6 +143,7 @@ | null - enable for HTTP requests, disable when running in CLI | */ - + 'disableRequestCache' => null, + ]; diff --git a/config/cms.php b/config/cms.php index 483d13fdfa..4da7fd4a7e 100644 --- a/config/cms.php +++ b/config/cms.php @@ -1,7 +1,7 @@ 'demo', - + /* |-------------------------------------------------------------------------- | Bleeding edge updates @@ -23,9 +23,9 @@ | and use the development copies of core files and plugins. | */ - + 'edgeUpdates' => false, - + /* |-------------------------------------------------------------------------- | Back-end URI prefix @@ -35,9 +35,9 @@ | For example: backend -> http://localhost/backend | */ - + 'backendUri' => 'backend', - + /* |-------------------------------------------------------------------------- | Back-end force HTTPS security @@ -48,9 +48,9 @@ | web server config, but can be handled by the app for added security. | */ - + 'backendForceSecure' => false, - + /* |-------------------------------------------------------------------------- | Back-end login remember @@ -66,9 +66,9 @@ | wanted behavior | */ - + 'backendForceRemember' => true, - + /* |-------------------------------------------------------------------------- | Back-end timezone @@ -79,9 +79,9 @@ | dates displayed in the back-end will be converted to this timezone. | */ - + 'backendTimezone' => 'UTC', - + /* |-------------------------------------------------------------------------- | Back-end Skin @@ -90,9 +90,9 @@ | Specifies the back-end skin to use. | */ - - 'backendSkin' => 'Backend\\Skins\\Standard', - + + 'backendSkin' => 'Backend\Skins\Standard', + /* |-------------------------------------------------------------------------- | Automatically run migrations on login @@ -105,9 +105,9 @@ | and disabled when debug mode is disabled. | */ - + 'runMigrationsOnLogin' => null, - + /* |-------------------------------------------------------------------------- | Determines which modules to load @@ -116,13 +116,9 @@ | Specify which modules should be registered when using the application. | */ - - 'loadModules' => [ - 'System', - 'Backend', - 'Cms', - ], - + + 'loadModules' => ['System', 'Backend', 'Cms'], + /* |-------------------------------------------------------------------------- | Prevents application updates @@ -134,9 +130,9 @@ | and themes will still be downloaded. | */ - + 'disableCoreUpdates' => false, - + /* |-------------------------------------------------------------------------- | Specific plugins to disable @@ -145,9 +141,9 @@ | Specify plugin codes which will always be disabled in the application. | */ - + 'disablePlugins' => [], - + /* |-------------------------------------------------------------------------- | Determines if the routing caching is enabled. @@ -159,9 +155,9 @@ | to disable the caching during the development, and enable it in the production mode. | */ - + 'enableRoutesCache' => false, - + /* |-------------------------------------------------------------------------- | Time to live for the URL map. @@ -172,9 +168,9 @@ | interval, in minutes, specified with the urlMapCacheTTL parameter expires. | */ - + 'urlCacheTtl' => 10, - + /* |-------------------------------------------------------------------------- | Time to live for parsed CMS objects. @@ -185,9 +181,9 @@ | the corresponding template file is modified. | */ - + 'parsedPageCacheTTL' => 10, - + /* |-------------------------------------------------------------------------- | Determines if the asset caching is enabled. @@ -199,9 +195,9 @@ | to disable the caching during the development, and enable it in the production mode. | */ - + 'enableAssetCache' => false, - + /* |-------------------------------------------------------------------------- | Determines if the asset minification is enabled. @@ -213,9 +209,9 @@ | when debug mode (app.debug) is disabled. | */ - + 'enableAssetMinify' => null, - + /* |-------------------------------------------------------------------------- | Check import timestamps when combining assets @@ -227,9 +223,9 @@ | is used when debug mode (app.debug) is enabled. | */ - + 'enableAssetDeepHashing' => null, - + /* |-------------------------------------------------------------------------- | Database-driven Themes @@ -253,9 +249,9 @@ | from the database. | */ - + 'databaseTemplates' => false, - + /* |-------------------------------------------------------------------------- | Public plugins path @@ -265,9 +261,9 @@ | or you can specify a full URL path. | */ - + 'pluginsPath' => '/plugins', - + /* |-------------------------------------------------------------------------- | Public themes path @@ -277,9 +273,9 @@ | or you can specify a full URL path. | */ - + 'themesPath' => '/themes', - + /* |-------------------------------------------------------------------------- | Resource storage @@ -314,26 +310,30 @@ | path for the uploads disk and `/projects/winter/storage/app/media` as | the path for the media disk. */ - + 'storage' => [ + 'uploads' => [ - 'disk' => 'local', - 'folder' => 'uploads', - 'path' => '/storage/app/uploads', + 'disk' => 'local', + 'folder' => 'uploads', + 'path' => '/storage/app/uploads', 'temporaryUrlTTL' => 3600, ], + 'media' => [ - 'disk' => 'local', + 'disk' => 'local', 'folder' => 'media', - 'path' => '/storage/app/media', + 'path' => '/storage/app/media', ], + 'resized' => [ - 'disk' => 'local', + 'disk' => 'local', 'folder' => 'resized', - 'path' => '/storage/app/resized', + 'path' => '/storage/app/resized', ], + ], - + /* |-------------------------------------------------------------------------- | Convert Line Endings @@ -343,9 +343,9 @@ | \r\n to the unix style \n. | */ - + 'convertLineEndings' => false, - + /* |-------------------------------------------------------------------------- | Linking policy @@ -359,9 +359,9 @@ | force - force hostname and schema using app.url config value | */ - + 'linkPolicy' => 'detect', - + /* |-------------------------------------------------------------------------- | Default permission mask @@ -370,12 +370,9 @@ | Specifies a default file and folder permission for newly created objects. | */ - - 'defaultMask' => [ - 'file' => null, - 'folder' => null, - ], - + + 'defaultMask' => ['file' => null, 'folder' => null], + /* |-------------------------------------------------------------------------- | Safe mode @@ -386,9 +383,9 @@ | debug mode (app.debug) is disabled. | */ - + 'enableSafeMode' => null, - + /* |-------------------------------------------------------------------------- | Cross Site Request Forgery (CSRF) Protection @@ -398,9 +395,9 @@ | checked for a valid security token. | */ - + 'enableCsrfProtection' => true, - + /* |-------------------------------------------------------------------------- | Force bytecode invalidation @@ -411,9 +408,9 @@ | cache won't update the cache, set to true to get around this. | */ - + 'forceBytecodeInvalidation' => true, - + /* |-------------------------------------------------------------------------- | Twig Strict Variables @@ -426,9 +423,9 @@ | enabled. | */ - + 'enableTwigStrictVariables' => false, - + /* |-------------------------------------------------------------------------- | Base Directory Restriction @@ -445,9 +442,9 @@ | NEVER have this disabled in production. | */ - + 'restrictBaseDir' => true, - + /* |-------------------------------------------------------------------------- | Backend Service Worker @@ -467,6 +464,7 @@ | false - disallow service workers to run in the backend | */ - + 'enableBackendServiceWorkers' => false, + ]; diff --git a/config/cookie.php b/config/cookie.php index a6c8528d76..f286fe5a6b 100644 --- a/config/cookie.php +++ b/config/cookie.php @@ -1,7 +1,7 @@ [], + + 'unencryptedCookies' => [ + // 'my_cookie', + ], + ]; diff --git a/config/database.php b/config/database.php index 5d4bd6c398..2d612ab1ce 100644 --- a/config/database.php +++ b/config/database.php @@ -1,7 +1,7 @@ env('DB_CONNECTION', 'mysql'), - + /* |-------------------------------------------------------------------------- | Database Connections @@ -29,63 +29,68 @@ | choice installed on your machine before you begin development. | */ - + 'connections' => [ + 'sqlite' => [ - 'database' => env('DB_DATABASE', storage_path('database.sqlite')), - 'driver' => 'sqlite', + 'database' => env('DB_DATABASE', storage_path('database.sqlite')), + 'driver' => 'sqlite', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), - 'prefix' => '', - 'url' => env('DATABASE_URL'), + 'prefix' => '', + 'url' => env('DATABASE_URL'), ], + 'mysql' => [ - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'mysql', - 'engine' => 'InnoDB', - 'host' => env('DB_HOST', '127.0.0.1'), - 'options' => extension_loaded('pdo_mysql') ? array_filter([ + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'mysql', + 'engine' => 'InnoDB', + 'host' => env('DB_HOST', '127.0.0.1'), + 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '3306'), - 'prefix' => '', + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '3306'), + 'prefix' => '', 'prefix_indexes' => true, - 'strict' => true, - 'unix_socket' => env('DB_SOCKET', ''), - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), - 'varcharmax' => 191, + 'strict' => true, + 'unix_socket' => env('DB_SOCKET', ''), + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), + 'varcharmax' => 191, ], + 'pgsql' => [ - 'charset' => 'utf8', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'pgsql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '5432'), - 'prefix' => '', + 'charset' => 'utf8', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'pgsql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '5432'), + 'prefix' => '', 'prefix_indexes' => true, - 'search_path' => 'public', - 'sslmode' => 'prefer', - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), + 'search_path' => 'public', + 'sslmode' => 'prefer', + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), ], + 'sqlsrv' => [ - 'charset' => 'utf8', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'sqlsrv', - 'host' => env('DB_HOST', '127.0.0.1'), - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '1433'), - 'prefix' => '', + 'charset' => 'utf8', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'sqlsrv', + 'host' => env('DB_HOST', '127.0.0.1'), + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '1433'), + 'prefix' => '', 'prefix_indexes' => true, - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), ], + ], - + /* |-------------------------------------------------------------------------- | Migration Repository Table @@ -96,9 +101,9 @@ | the migrations on disk haven't actually been run in the database. | */ - + 'migrations' => 'migrations', - + /* |-------------------------------------------------------------------------- | Redis Databases @@ -109,26 +114,32 @@ | such as APC or Memcached. Winter makes it easy to dig right in. | */ - + 'redis' => [ + 'client' => env('REDIS_CLIENT', 'phpredis'), + 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', str_slug(env('APP_NAME', 'winter'), '_') . '_database_'), + 'prefix' => env('REDIS_PREFIX', str_slug(env('APP_NAME', 'winter'), '_').'_database_'), ], + 'default' => [ 'database' => env('REDIS_DB', '0'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'url' => env('REDIS_URL'), + 'port' => env('REDIS_PORT', '6379'), + 'url' => env('REDIS_URL'), ], + 'cache' => [ 'database' => env('REDIS_CACHE_DB', '1'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'url' => env('REDIS_URL'), + 'port' => env('REDIS_PORT', '6379'), + 'url' => env('REDIS_URL'), ], + ], + ]; diff --git a/config/develop.php b/config/develop.php index 47c89175c8..381b56409d 100644 --- a/config/develop.php +++ b/config/develop.php @@ -1,7 +1,7 @@ false, - + /* |-------------------------------------------------------------------------- | Allow deep-level symlinks @@ -40,6 +40,7 @@ | false - only allow symlinks at the first level of subdirectories (default) | */ - + 'allowDeepSymlinks' => false, + ]; diff --git a/config/environment.php b/config/environment.php index fb17f634df..5249b15bad 100644 --- a/config/environment.php +++ b/config/environment.php @@ -1,7 +1,7 @@ 'development', - + /* |-------------------------------------------------------------------------- | Environment Multitenancy @@ -25,8 +25,11 @@ | different configuration, such as database and theme, per hostname. | */ - + 'hosts' => [ + 'localhost' => 'dev', + ], + ]; diff --git a/config/filesystems.php b/config/filesystems.php index 0fc1103700..a85fcc8a9e 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -1,7 +1,7 @@ env('FILESYSTEM_DISK', 'local'), - + /* |-------------------------------------------------------------------------- | Filesystem Disks @@ -27,22 +27,26 @@ | Supported Drivers: "local", "ftp", "sftp", "s3" | */ - + 'disks' => [ + 'local' => [ 'driver' => 'local', - 'root' => storage_path('app'), - 'url' => '/storage/app', + 'root' => storage_path('app'), + 'url' => '/storage/app', ], + 's3' => [ - 'bucket' => env('AWS_BUCKET'), - 'driver' => 's3', - 'endpoint' => env('AWS_ENDPOINT'), - 'key' => env('AWS_ACCESS_KEY_ID'), - 'region' => env('AWS_DEFAULT_REGION'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'url' => env('AWS_URL'), + 'bucket' => env('AWS_BUCKET'), + 'driver' => 's3', + 'endpoint' => env('AWS_ENDPOINT'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'region' => env('AWS_DEFAULT_REGION'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'url' => env('AWS_URL'), 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), ], + ], + ]; diff --git a/config/hashing.php b/config/hashing.php index f8c867896a..616059443b 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -1,7 +1,7 @@ 'bcrypt', - + /* |-------------------------------------------------------------------------- | Bcrypt Options @@ -27,11 +27,11 @@ | to control the amount of time it takes to hash the given password. | */ - + 'bcrypt' => [ 'rounds' => env('BCRYPT_ROUNDS', 10), ], - + /* |-------------------------------------------------------------------------- | Argon Options @@ -42,10 +42,11 @@ | to control the amount of time it takes to hash the given password. | */ - + 'argon' => [ - 'memory' => 65536, + 'memory' => 65536, 'threads' => 1, - 'time' => 4, + 'time' => 4, ], + ]; diff --git a/config/logging.php b/config/logging.php index e60a3fa51f..e7ea8f3bb6 100644 --- a/config/logging.php +++ b/config/logging.php @@ -1,7 +1,7 @@ env('LOG_CHANNEL', 'stack'), - + /* |-------------------------------------------------------------------------- | Deprecations Log Channel @@ -25,9 +25,9 @@ | your application ready for upcoming major versions of dependencies. | */ - + 'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), - + /* |-------------------------------------------------------------------------- | Log Channels @@ -42,66 +42,74 @@ | "custom", "stack" | */ - + 'channels' => [ 'stack' => [ - 'channels' => [ - 'single', - ], - 'driver' => 'stack', + 'channels' => ['single'], + 'driver' => 'stack', 'ignore_exceptions' => false, ], + 'single' => [ 'driver' => 'single', - 'level' => env('LOG_LEVEL', 'debug'), - 'path' => storage_path('logs/system.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'path' => storage_path('logs/system.log'), ], + 'daily' => [ - 'days' => 14, + 'days' => 14, 'driver' => 'daily', - 'level' => env('LOG_LEVEL', 'debug'), - 'path' => storage_path('logs/system.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'path' => storage_path('logs/system.log'), ], + 'slack' => [ - 'driver' => 'slack', - 'emoji' => ':boom:', - 'level' => env('LOG_LEVEL', 'critical'), - 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'driver' => 'slack', + 'emoji' => ':boom:', + 'level' => env('LOG_LEVEL', 'critical'), + 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Winter Log', ], + 'papertrail' => [ - 'driver' => 'monolog', - 'handler' => env('LOG_PAPERTRAIL_HANDLER', \Monolog\Handler\SyslogUdpHandler::class), + 'driver' => 'monolog', + 'handler' => env('LOG_PAPERTRAIL_HANDLER', \Monolog\Handler\SyslogUdpHandler::class), 'handler_with' => [ - 'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'), - 'host' => env('PAPERTRAIL_URL'), - 'port' => env('PAPERTRAIL_PORT'), + 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), + 'host' => env('PAPERTRAIL_URL'), + 'port' => env('PAPERTRAIL_PORT'), ], - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], + 'stderr' => [ - 'driver' => 'monolog', + 'driver' => 'monolog', 'formatter' => env('LOG_STDERR_FORMATTER'), - 'handler' => \Monolog\Handler\StreamHandler::class, - 'level' => env('LOG_LEVEL', 'debug'), - 'with' => [ + 'handler' => \Monolog\Handler\StreamHandler::class, + 'level' => env('LOG_LEVEL', 'debug'), + 'with' => [ 'stream' => 'php://stderr', ], ], + 'syslog' => [ 'driver' => 'syslog', - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], + 'errorlog' => [ 'driver' => 'errorlog', - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], + 'null' => [ - 'driver' => 'monolog', + 'driver' => 'monolog', 'handler' => \Monolog\Handler\NullHandler::class, ], + 'emergency' => [ 'path' => storage_path('logs/system.log'), ], ], + ]; diff --git a/config/mail.php b/config/mail.php index d1c10db337..25a896d141 100644 --- a/config/mail.php +++ b/config/mail.php @@ -1,7 +1,7 @@ env('MAIL_MAILER', 'smtp'), - + /* |-------------------------------------------------------------------------- | Mailer Configurations @@ -32,46 +32,53 @@ | "postmark", "log", "array", "failover" | */ - + 'mailers' => [ 'smtp' => [ 'encryption' => env('MAIL_ENCRYPTION', 'tls'), - 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), - 'password' => env('MAIL_PASSWORD'), - 'port' => env('MAIL_PORT', 587), - 'timeout' => null, - 'transport' => 'smtp', - 'username' => env('MAIL_USERNAME'), + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), + 'password' => env('MAIL_PASSWORD'), + 'port' => env('MAIL_PORT', 587), + 'timeout' => null, + 'transport' => 'smtp', + 'username' => env('MAIL_USERNAME'), ], + 'ses' => [ 'transport' => 'ses', ], + 'mailgun' => [ 'transport' => 'mailgun', ], + 'postmark' => [ 'transport' => 'postmark', ], + 'sendmail' => [ - 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), + 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), 'transport' => 'sendmail', ], + 'log' => [ - 'channel' => env('MAIL_LOG_CHANNEL'), + 'channel' => env('MAIL_LOG_CHANNEL'), 'transport' => 'log', ], + 'array' => [ 'transport' => 'array', ], + 'failover' => [ - 'mailers' => [ + 'mailers' => [ 'smtp', 'log', ], 'transport' => 'failover', ], ], - + /* |-------------------------------------------------------------------------- | Global "From" Address @@ -82,9 +89,10 @@ | used globally for all e-mails that are sent by your application. | */ - + 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'noreply@example.com'), - 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Winter CMS')), + 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Winter CMS')), ], + ]; diff --git a/config/queue.php b/config/queue.php index 569d9ee426..ba40614d70 100644 --- a/config/queue.php +++ b/config/queue.php @@ -1,7 +1,7 @@ env('QUEUE_CONNECTION', 'sync'), - + /* |-------------------------------------------------------------------------- | Queue Connections @@ -27,46 +27,52 @@ | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" | */ - + 'connections' => [ + 'sync' => [ 'driver' => 'sync', ], + 'database' => [ 'after_commit' => false, - 'driver' => 'database', - 'queue' => 'default', - 'retry_after' => 90, - 'table' => 'jobs', + 'driver' => 'database', + 'queue' => 'default', + 'retry_after' => 90, + 'table' => 'jobs', ], + 'beanstalkd' => [ 'after_commit' => false, - 'block_for' => 0, - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, + 'block_for' => 0, + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'retry_after' => 90, ], + 'sqs' => [ 'after_commit' => false, - 'driver' => 'sqs', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), - 'queue' => env('SQS_QUEUE', 'default'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'suffix' => env('SQS_SUFFIX'), + 'driver' => 'sqs', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'default'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'suffix' => env('SQS_SUFFIX'), ], + 'redis' => [ 'after_commit' => false, - 'block_for' => null, - 'connection' => 'default', - 'driver' => 'redis', - 'queue' => env('REDIS_QUEUE', 'default'), - 'retry_after' => 90, + 'block_for' => null, + 'connection' => 'default', + 'driver' => 'redis', + 'queue' => env('REDIS_QUEUE', 'default'), + 'retry_after' => 90, ], + ], - + /* |-------------------------------------------------------------------------- | Failed Queue Jobs @@ -77,10 +83,11 @@ | have failed. You may change them to any database / table you wish. | */ - + 'failed' => [ 'database' => env('DB_CONNECTION', 'mysql'), - 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), - 'table' => 'failed_jobs', + 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), + 'table' => 'failed_jobs', ], + ]; diff --git a/config/services.php b/config/services.php index d2cf8694bb..32760c1d49 100644 --- a/config/services.php +++ b/config/services.php @@ -1,7 +1,7 @@ [ - 'domain' => env('MAILGUN_DOMAIN'), + 'domain' => env('MAILGUN_DOMAIN'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), - 'secret' => env('MAILGUN_SECRET'), + 'secret' => env('MAILGUN_SECRET'), ], + 'postmark' => [ 'token' => env('POSTMARK_TOKEN'), ], + 'ses' => [ - 'key' => env('AWS_ACCESS_KEY_ID'), + 'key' => env('AWS_ACCESS_KEY_ID'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), ], + ]; diff --git a/config/session.php b/config/session.php index 73b725aaf9..78aac1472e 100644 --- a/config/session.php +++ b/config/session.php @@ -1,7 +1,7 @@ env('SESSION_DRIVER', 'file'), - + /* |-------------------------------------------------------------------------- | Session Lifetime @@ -28,10 +28,11 @@ | to immediately expire on the browser closing, set that option. | */ - + 'lifetime' => env('SESSION_LIFETIME', 120), + 'expire_on_close' => false, - + /* |-------------------------------------------------------------------------- | Session Encryption @@ -42,9 +43,9 @@ | automatically by Laravel and you can use the Session like normal. | */ - + 'encrypt' => false, - + /* |-------------------------------------------------------------------------- | Session File Location @@ -55,9 +56,9 @@ | location may be specified. This is only needed for file sessions. | */ - + 'files' => storage_path('framework/sessions'), - + /* |-------------------------------------------------------------------------- | Session Database Connection @@ -68,9 +69,9 @@ | correspond to a connection in your database configuration options. | */ - + 'connection' => env('SESSION_CONNECTION'), - + /* |-------------------------------------------------------------------------- | Session Database Table @@ -81,9 +82,9 @@ | provided for you; however, you are free to change this as needed. | */ - + 'table' => 'sessions', - + /* |-------------------------------------------------------------------------- | Session Cache Store @@ -96,9 +97,9 @@ | Affects: "apc", "dynamodb", "memcached", "redis" | */ - + 'store' => env('SESSION_STORE'), - + /* |-------------------------------------------------------------------------- | Session Sweeping Lottery @@ -109,12 +110,9 @@ | happen on a given request. By default, the odds are 2 out of 100. | */ - - 'lottery' => [ - 2, - 100, - ], - + + 'lottery' => [2, 100], + /* |-------------------------------------------------------------------------- | Session Cookie Name @@ -125,9 +123,12 @@ | new session cookie is created by the framework for every driver. | */ - - 'cookie' => env('SESSION_COOKIE', str_slug(env('APP_NAME', 'winter'), '_') . '_session'), - + + 'cookie' => env( + 'SESSION_COOKIE', + str_slug(env('APP_NAME', 'winter'), '_').'_session' + ), + /* |-------------------------------------------------------------------------- | Session Cookie Path @@ -138,9 +139,9 @@ | your application but you are free to change this when necessary. | */ - + 'path' => '/', - + /* |-------------------------------------------------------------------------- | Session Cookie Domain @@ -151,9 +152,9 @@ | available to in your application. A sensible default has been set. | */ - + 'domain' => env('SESSION_DOMAIN'), - + /* |-------------------------------------------------------------------------- | HTTP Access Only @@ -164,9 +165,9 @@ | the HTTP protocol. You are free to modify this option if needed. | */ - + 'http_only' => true, - + /* |-------------------------------------------------------------------------- | HTTPS Only Cookies @@ -177,9 +178,9 @@ | the cookie from being sent to you when it can't be done securely. | */ - + 'secure' => env('SESSION_SECURE_COOKIE', false), - + /* |-------------------------------------------------------------------------- | Same-Site Cookies @@ -211,6 +212,7 @@ | Supported: "lax", "strict", "none", null | */ - + 'same_site' => 'lax', + ]; diff --git a/config/view.php b/config/view.php index e38f47fd31..bbbb7327e0 100644 --- a/config/view.php +++ b/config/view.php @@ -1,7 +1,7 @@ [], - + + 'paths' => [ + // Default Laravel Blade template location + // @see https://github.com/octobercms/october/issues/3473 & https://github.com/octobercms/october/issues/3459 + // realpath(base_path('resources/views')) + ], + /* |-------------------------------------------------------------------------- | Compiled View Path @@ -25,6 +29,10 @@ | directory. However, as usual, you are free to change this value. | */ - - 'compiled' => env('VIEW_COMPILED_PATH', realpath(storage_path('framework/views'))), + + 'compiled' => env( + 'VIEW_COMPILED_PATH', + realpath(storage_path('framework/views')) + ), + ]; From 520190f5e0079fc2001269305889930de66bd77d Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Tue, 15 Mar 2022 21:26:52 -0600 Subject: [PATCH 13/16] Tweaks to be more friendly with the ArrayFile parser --- config/app.php | 2 +- config/auth.php | 10 +++++++--- config/cms.php | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config/app.php b/config/app.php index 4ba2ad7f91..f874d92d8e 100644 --- a/config/app.php +++ b/config/app.php @@ -249,7 +249,7 @@ // 'Illuminate\Html\HtmlServiceProvider', // Example - 'System\ServiceProvider', + System\ServiceProvider::class, ]), /* diff --git a/config/auth.php b/config/auth.php index 8dc13b61c7..1d0408d9da 100644 --- a/config/auth.php +++ b/config/auth.php @@ -3,6 +3,7 @@ return [ 'throttle' => [ + /* |-------------------------------------------------------------------------- | Enable throttling of Backend authentication attempts @@ -11,7 +12,8 @@ | If set to true, users will be given a limited number of attempts to sign | in to the Backend before being blocked for a specified number of minutes. | - */ + */ + 'enabled' => true, /* @@ -21,7 +23,8 @@ | | Number of failed attempts allowed while trying to authenticate a user. | - */ + */ + 'attemptLimit' => 5, /* @@ -32,7 +35,8 @@ | The number of minutes to suspend further attempts on authentication once | the attempt limit is reached. | - */ + */ + 'suspensionTime' => 15, ], diff --git a/config/cms.php b/config/cms.php index c906b5c6eb..85fd51f856 100644 --- a/config/cms.php +++ b/config/cms.php @@ -91,7 +91,7 @@ | */ - 'backendSkin' => 'Backend\Skins\Standard', + 'backendSkin' => \Backend\Skins\Standard::class, /* |-------------------------------------------------------------------------- From cd9f9097e810806a67ddd85499f9af3a99aaaf11 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Tue, 15 Mar 2022 21:52:46 -0600 Subject: [PATCH 14/16] Style fix --- modules/system/console/WinterInstall.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/system/console/WinterInstall.php b/modules/system/console/WinterInstall.php index dbec0fdbb0..bc7e3fd964 100644 --- a/modules/system/console/WinterInstall.php +++ b/modules/system/console/WinterInstall.php @@ -462,4 +462,4 @@ protected function getConfigFile($name = 'app') return $path; } -} \ No newline at end of file +} From c1377604980e60f1b8bd1799721b0ce543f4c501 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 16 Mar 2022 10:55:07 -0600 Subject: [PATCH 15/16] Run all config files through ArrayFile parser This will minimize changes when ConfigWriter is used to set config values through PHP. --- config/app.php | 4 -- config/auth.php | 3 +- config/broadcasting.php | 23 ++++----- config/cache.php | 42 +++++++---------- config/cms.php | 30 ++++++------ config/cookie.php | 1 - config/database.php | 101 ++++++++++++++++++---------------------- config/develop.php | 1 - config/environment.php | 3 -- config/filesystems.php | 22 ++++----- config/hashing.php | 5 +- config/logging.php | 60 +++++++++++------------- config/mail.php | 28 ++++------- config/queue.php | 53 +++++++++------------ config/services.php | 9 ++-- config/session.php | 12 ++--- config/view.php | 6 +-- 17 files changed, 165 insertions(+), 238 deletions(-) diff --git a/config/app.php b/config/app.php index f874d92d8e..c4d3537fc2 100644 --- a/config/app.php +++ b/config/app.php @@ -231,7 +231,6 @@ */ 'key' => env('APP_KEY'), - 'cipher' => 'AES-256-CBC', /* @@ -284,9 +283,6 @@ */ 'aliases' => array_merge(include(base_path('modules/system/aliases.php')), [ - // 'Str' => 'Illuminate\Support\Str', // Example - ]), - ]; diff --git a/config/auth.php b/config/auth.php index 9f4174709d..846e31a593 100644 --- a/config/auth.php +++ b/config/auth.php @@ -1,8 +1,8 @@ [ + /* |-------------------------------------------------------------------------- | Enable throttling of Backend authentication attempts @@ -38,5 +38,4 @@ 'suspensionTime' => 15, ], - ]; diff --git a/config/broadcasting.php b/config/broadcasting.php index 542f5f1de3..948f010a11 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -29,39 +29,32 @@ */ 'connections' => [ - 'pusher' => [ - 'app_id' => env('PUSHER_APP_ID'), + 'app_id' => env('PUSHER_APP_ID'), 'client_options' => [ // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html ], - 'driver' => 'pusher', - 'key' => env('PUSHER_APP_KEY'), - 'options' => [ + 'driver' => 'pusher', + 'key' => env('PUSHER_APP_KEY'), + 'options' => [ 'cluster' => env('PUSHER_APP_CLUSTER'), - 'useTLS' => true, + 'useTLS' => true, ], - 'secret' => env('PUSHER_APP_SECRET'), + 'secret' => env('PUSHER_APP_SECRET'), ], - 'ably' => [ 'driver' => 'ably', - 'key' => env('ABLY_KEY'), + 'key' => env('ABLY_KEY'), ], - 'redis' => [ 'connection' => 'default', - 'driver' => 'redis', + 'driver' => 'redis', ], - 'log' => [ 'driver' => 'log', ], - 'null' => [ 'driver' => 'null', ], - ], - ]; diff --git a/config/cache.php b/config/cache.php index e2bba31603..c689a4ba53 100644 --- a/config/cache.php +++ b/config/cache.php @@ -35,31 +35,26 @@ */ 'stores' => [ - 'apc' => [ 'driver' => 'apc', ], - 'array' => [ - 'driver' => 'array', + 'driver' => 'array', 'serialize' => false, ], - 'database' => [ - 'connection' => null, - 'driver' => 'database', + 'connection' => null, + 'driver' => 'database', 'lock_connection' => null, - 'table' => 'cache', + 'table' => 'cache', ], - 'file' => [ 'driver' => 'file', - 'path' => storage_path('framework/cache'), + 'path' => storage_path('framework/cache'), ], - 'memcached' => [ - 'driver' => 'memcached', - 'options' => [ + 'driver' => 'memcached', + 'options' => [ // Memcached::OPT_CONNECT_TIMEOUT => 2000, ], 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), @@ -67,7 +62,7 @@ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], - 'servers' => [ + 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 'port' => env('MEMCACHED_PORT', 11211), @@ -75,26 +70,22 @@ ], ], ], - 'redis' => [ - 'connection' => 'cache', - 'driver' => 'redis', + 'connection' => 'cache', + 'driver' => 'redis', 'lock_connection' => 'default', ], - 'dynamodb' => [ - 'driver' => 'dynamodb', + 'driver' => 'dynamodb', 'endpoint' => env('DYNAMODB_ENDPOINT'), - 'key' => env('AWS_ACCESS_KEY_ID'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), ], - 'octane' => [ 'driver' => 'octane', ], - ], /* @@ -108,7 +99,7 @@ | */ - 'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'winter'), '_').'_cache'), + 'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'winter'), '_') . '_cache'), /* |-------------------------------------------------------------------------- @@ -145,5 +136,4 @@ */ 'disableRequestCache' => null, - ]; diff --git a/config/cms.php b/config/cms.php index 85fd51f856..560491de72 100644 --- a/config/cms.php +++ b/config/cms.php @@ -117,7 +117,11 @@ | */ - 'loadModules' => ['System', 'Backend', 'Cms'], + 'loadModules' => [ + 'System', + 'Backend', + 'Cms', + ], /* |-------------------------------------------------------------------------- @@ -312,26 +316,22 @@ */ 'storage' => [ - 'uploads' => [ - 'disk' => 'local', - 'folder' => 'uploads', - 'path' => '/storage/app/uploads', + 'disk' => 'local', + 'folder' => 'uploads', + 'path' => '/storage/app/uploads', 'temporaryUrlTTL' => 3600, ], - 'media' => [ - 'disk' => 'local', + 'disk' => 'local', 'folder' => 'media', - 'path' => '/storage/app/media', + 'path' => '/storage/app/media', ], - 'resized' => [ - 'disk' => 'local', + 'disk' => 'local', 'folder' => 'resized', - 'path' => '/storage/app/resized', + 'path' => '/storage/app/resized', ], - ], /* @@ -371,7 +371,10 @@ | */ - 'defaultMask' => ['file' => null, 'folder' => null], + 'defaultMask' => [ + 'file' => null, + 'folder' => null, + ], /* |-------------------------------------------------------------------------- @@ -466,5 +469,4 @@ */ 'enableBackendServiceWorkers' => false, - ]; diff --git a/config/cookie.php b/config/cookie.php index f286fe5a6b..654d29df81 100644 --- a/config/cookie.php +++ b/config/cookie.php @@ -17,5 +17,4 @@ 'unencryptedCookies' => [ // 'my_cookie', ], - ]; diff --git a/config/database.php b/config/database.php index e597bf084e..f57e26acac 100644 --- a/config/database.php +++ b/config/database.php @@ -31,63 +31,58 @@ */ 'connections' => [ - 'sqlite' => [ - 'database' => env('DB_DATABASE', storage_path('database.sqlite')), - 'driver' => 'sqlite', + 'database' => env('DB_DATABASE', storage_path('database.sqlite')), + 'driver' => 'sqlite', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), - 'prefix' => '', - 'url' => env('DATABASE_URL'), + 'prefix' => '', + 'url' => env('DATABASE_URL'), ], - 'mysql' => [ - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'mysql', - 'engine' => 'InnoDB', - 'host' => env('DB_HOST', '127.0.0.1'), - 'options' => extension_loaded('pdo_mysql') ? array_filter([ + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'mysql', + 'engine' => 'InnoDB', + 'host' => env('DB_HOST', '127.0.0.1'), + 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '3306'), - 'prefix' => '', + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '3306'), + 'prefix' => '', 'prefix_indexes' => true, - 'strict' => true, - 'unix_socket' => env('DB_SOCKET', ''), - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), + 'strict' => true, + 'unix_socket' => env('DB_SOCKET', ''), + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), ], - 'pgsql' => [ - 'charset' => 'utf8', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'pgsql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '5432'), - 'prefix' => '', + 'charset' => 'utf8', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'pgsql', + 'host' => env('DB_HOST', '127.0.0.1'), + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '5432'), + 'prefix' => '', 'prefix_indexes' => true, - 'search_path' => 'public', - 'sslmode' => 'prefer', - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), + 'search_path' => 'public', + 'sslmode' => 'prefer', + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), ], - 'sqlsrv' => [ - 'charset' => 'utf8', - 'database' => env('DB_DATABASE', 'winter'), - 'driver' => 'sqlsrv', - 'host' => env('DB_HOST', '127.0.0.1'), - 'password' => env('DB_PASSWORD', ''), - 'port' => env('DB_PORT', '1433'), - 'prefix' => '', + 'charset' => 'utf8', + 'database' => env('DB_DATABASE', 'winter'), + 'driver' => 'sqlsrv', + 'host' => env('DB_HOST', '127.0.0.1'), + 'password' => env('DB_PASSWORD', ''), + 'port' => env('DB_PORT', '1433'), + 'prefix' => '', 'prefix_indexes' => true, - 'url' => env('DATABASE_URL'), - 'username' => env('DB_USERNAME', 'winter'), + 'url' => env('DATABASE_URL'), + 'username' => env('DB_USERNAME', 'winter'), ], - ], /* @@ -115,30 +110,24 @@ */ 'redis' => [ - 'client' => env('REDIS_CLIENT', 'phpredis'), - 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', str_slug(env('APP_NAME', 'winter'), '_').'_database_'), + 'prefix' => env('REDIS_PREFIX', str_slug(env('APP_NAME', 'winter'), '_') . '_database_'), ], - 'default' => [ 'database' => env('REDIS_DB', '0'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'url' => env('REDIS_URL'), + 'port' => env('REDIS_PORT', '6379'), + 'url' => env('REDIS_URL'), ], - 'cache' => [ 'database' => env('REDIS_CACHE_DB', '1'), - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD'), - 'port' => env('REDIS_PORT', '6379'), - 'url' => env('REDIS_URL'), + 'port' => env('REDIS_PORT', '6379'), + 'url' => env('REDIS_URL'), ], - ], - ]; diff --git a/config/develop.php b/config/develop.php index 381b56409d..4a30178b51 100644 --- a/config/develop.php +++ b/config/develop.php @@ -42,5 +42,4 @@ */ 'allowDeepSymlinks' => false, - ]; diff --git a/config/environment.php b/config/environment.php index 5249b15bad..caa9f6581c 100644 --- a/config/environment.php +++ b/config/environment.php @@ -27,9 +27,6 @@ */ 'hosts' => [ - 'localhost' => 'dev', - ], - ]; diff --git a/config/filesystems.php b/config/filesystems.php index a85fcc8a9e..7e11f19981 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -29,24 +29,20 @@ */ 'disks' => [ - 'local' => [ 'driver' => 'local', - 'root' => storage_path('app'), - 'url' => '/storage/app', + 'root' => storage_path('app'), + 'url' => '/storage/app', ], - 's3' => [ - 'bucket' => env('AWS_BUCKET'), - 'driver' => 's3', - 'endpoint' => env('AWS_ENDPOINT'), - 'key' => env('AWS_ACCESS_KEY_ID'), - 'region' => env('AWS_DEFAULT_REGION'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'url' => env('AWS_URL'), + 'bucket' => env('AWS_BUCKET'), + 'driver' => 's3', + 'endpoint' => env('AWS_ENDPOINT'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'region' => env('AWS_DEFAULT_REGION'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'url' => env('AWS_URL'), 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), ], - ], - ]; diff --git a/config/hashing.php b/config/hashing.php index 616059443b..ad56664fb1 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -44,9 +44,8 @@ */ 'argon' => [ - 'memory' => 65536, + 'memory' => 65536, 'threads' => 1, - 'time' => 4, + 'time' => 4, ], - ]; diff --git a/config/logging.php b/config/logging.php index e7ea8f3bb6..415941e91c 100644 --- a/config/logging.php +++ b/config/logging.php @@ -45,71 +45,63 @@ 'channels' => [ 'stack' => [ - 'channels' => ['single'], - 'driver' => 'stack', + 'channels' => [ + 'single', + ], + 'driver' => 'stack', 'ignore_exceptions' => false, ], - 'single' => [ 'driver' => 'single', - 'level' => env('LOG_LEVEL', 'debug'), - 'path' => storage_path('logs/system.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'path' => storage_path('logs/system.log'), ], - 'daily' => [ - 'days' => 14, + 'days' => 14, 'driver' => 'daily', - 'level' => env('LOG_LEVEL', 'debug'), - 'path' => storage_path('logs/system.log'), + 'level' => env('LOG_LEVEL', 'debug'), + 'path' => storage_path('logs/system.log'), ], - 'slack' => [ - 'driver' => 'slack', - 'emoji' => ':boom:', - 'level' => env('LOG_LEVEL', 'critical'), - 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'driver' => 'slack', + 'emoji' => ':boom:', + 'level' => env('LOG_LEVEL', 'critical'), + 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Winter Log', ], - 'papertrail' => [ - 'driver' => 'monolog', - 'handler' => env('LOG_PAPERTRAIL_HANDLER', \Monolog\Handler\SyslogUdpHandler::class), + 'driver' => 'monolog', + 'handler' => env('LOG_PAPERTRAIL_HANDLER', \Monolog\Handler\SyslogUdpHandler::class), 'handler_with' => [ - 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), - 'host' => env('PAPERTRAIL_URL'), - 'port' => env('PAPERTRAIL_PORT'), + 'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'), + 'host' => env('PAPERTRAIL_URL'), + 'port' => env('PAPERTRAIL_PORT'), ], - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], - 'stderr' => [ - 'driver' => 'monolog', + 'driver' => 'monolog', 'formatter' => env('LOG_STDERR_FORMATTER'), - 'handler' => \Monolog\Handler\StreamHandler::class, - 'level' => env('LOG_LEVEL', 'debug'), - 'with' => [ + 'handler' => \Monolog\Handler\StreamHandler::class, + 'level' => env('LOG_LEVEL', 'debug'), + 'with' => [ 'stream' => 'php://stderr', ], ], - 'syslog' => [ 'driver' => 'syslog', - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], - 'errorlog' => [ 'driver' => 'errorlog', - 'level' => env('LOG_LEVEL', 'debug'), + 'level' => env('LOG_LEVEL', 'debug'), ], - 'null' => [ - 'driver' => 'monolog', + 'driver' => 'monolog', 'handler' => \Monolog\Handler\NullHandler::class, ], - 'emergency' => [ 'path' => storage_path('logs/system.log'), ], ], - ]; diff --git a/config/mail.php b/config/mail.php index 25a896d141..03eae82251 100644 --- a/config/mail.php +++ b/config/mail.php @@ -36,42 +36,35 @@ 'mailers' => [ 'smtp' => [ 'encryption' => env('MAIL_ENCRYPTION', 'tls'), - 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), - 'password' => env('MAIL_PASSWORD'), - 'port' => env('MAIL_PORT', 587), - 'timeout' => null, - 'transport' => 'smtp', - 'username' => env('MAIL_USERNAME'), + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), + 'password' => env('MAIL_PASSWORD'), + 'port' => env('MAIL_PORT', 587), + 'timeout' => null, + 'transport' => 'smtp', + 'username' => env('MAIL_USERNAME'), ], - 'ses' => [ 'transport' => 'ses', ], - 'mailgun' => [ 'transport' => 'mailgun', ], - 'postmark' => [ 'transport' => 'postmark', ], - 'sendmail' => [ - 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), + 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), 'transport' => 'sendmail', ], - 'log' => [ - 'channel' => env('MAIL_LOG_CHANNEL'), + 'channel' => env('MAIL_LOG_CHANNEL'), 'transport' => 'log', ], - 'array' => [ 'transport' => 'array', ], - 'failover' => [ - 'mailers' => [ + 'mailers' => [ 'smtp', 'log', ], @@ -92,7 +85,6 @@ 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'noreply@example.com'), - 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Winter CMS')), + 'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Winter CMS')), ], - ]; diff --git a/config/queue.php b/config/queue.php index ba40614d70..342b9d650d 100644 --- a/config/queue.php +++ b/config/queue.php @@ -29,48 +29,42 @@ */ 'connections' => [ - 'sync' => [ 'driver' => 'sync', ], - 'database' => [ 'after_commit' => false, - 'driver' => 'database', - 'queue' => 'default', - 'retry_after' => 90, - 'table' => 'jobs', + 'driver' => 'database', + 'queue' => 'default', + 'retry_after' => 90, + 'table' => 'jobs', ], - 'beanstalkd' => [ 'after_commit' => false, - 'block_for' => 0, - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, + 'block_for' => 0, + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'retry_after' => 90, ], - 'sqs' => [ 'after_commit' => false, - 'driver' => 'sqs', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), - 'queue' => env('SQS_QUEUE', 'default'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'suffix' => env('SQS_SUFFIX'), + 'driver' => 'sqs', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'default'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'suffix' => env('SQS_SUFFIX'), ], - 'redis' => [ 'after_commit' => false, - 'block_for' => null, - 'connection' => 'default', - 'driver' => 'redis', - 'queue' => env('REDIS_QUEUE', 'default'), - 'retry_after' => 90, + 'block_for' => null, + 'connection' => 'default', + 'driver' => 'redis', + 'queue' => env('REDIS_QUEUE', 'default'), + 'retry_after' => 90, ], - ], /* @@ -86,8 +80,7 @@ 'failed' => [ 'database' => env('DB_CONNECTION', 'mysql'), - 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), - 'table' => 'failed_jobs', + 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), + 'table' => 'failed_jobs', ], - ]; diff --git a/config/services.php b/config/services.php index 32760c1d49..fd9b6e0161 100644 --- a/config/services.php +++ b/config/services.php @@ -15,19 +15,16 @@ */ 'mailgun' => [ - 'domain' => env('MAILGUN_DOMAIN'), + 'domain' => env('MAILGUN_DOMAIN'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), - 'secret' => env('MAILGUN_SECRET'), + 'secret' => env('MAILGUN_SECRET'), ], - 'postmark' => [ 'token' => env('POSTMARK_TOKEN'), ], - 'ses' => [ - 'key' => env('AWS_ACCESS_KEY_ID'), + 'key' => env('AWS_ACCESS_KEY_ID'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), ], - ]; diff --git a/config/session.php b/config/session.php index 78aac1472e..2137951367 100644 --- a/config/session.php +++ b/config/session.php @@ -30,7 +30,6 @@ */ 'lifetime' => env('SESSION_LIFETIME', 120), - 'expire_on_close' => false, /* @@ -111,7 +110,10 @@ | */ - 'lottery' => [2, 100], + 'lottery' => [ + 2, + 100, + ], /* |-------------------------------------------------------------------------- @@ -124,10 +126,7 @@ | */ - 'cookie' => env( - 'SESSION_COOKIE', - str_slug(env('APP_NAME', 'winter'), '_').'_session' - ), + 'cookie' => env('SESSION_COOKIE', str_slug(env('APP_NAME', 'winter'), '_') . '_session'), /* |-------------------------------------------------------------------------- @@ -214,5 +213,4 @@ */ 'same_site' => 'lax', - ]; diff --git a/config/view.php b/config/view.php index bbbb7327e0..63394f68a5 100644 --- a/config/view.php +++ b/config/view.php @@ -30,9 +30,5 @@ | */ - 'compiled' => env( - 'VIEW_COMPILED_PATH', - realpath(storage_path('framework/views')) - ), - + 'compiled' => env('VIEW_COMPILED_PATH', realpath(storage_path('framework/views'))), ]; From f2d9526d298d7c03c74f95017a2466ee796d7bb6 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Wed, 16 Mar 2022 14:51:21 -0600 Subject: [PATCH 16/16] Support new mail config file structure --- modules/system/console/WinterEnv.php | 85 +++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 9 deletions(-) diff --git a/modules/system/console/WinterEnv.php b/modules/system/console/WinterEnv.php index c7356cdd83..2cafbe764d 100644 --- a/modules/system/console/WinterEnv.php +++ b/modules/system/console/WinterEnv.php @@ -1,8 +1,8 @@ laravel->environmentFilePath())) { - $this->error('.env file already exists (' . $this->laravel->environmentFilePath() . ')'); + if ( + file_exists($this->laravel->environmentFilePath()) + && !$this->confirmToProceed() + ) { return 1; } @@ -68,6 +69,34 @@ public function handle(): int return 0; } + /** + * Confirm before proceeding with the action. + * + * This method only asks for confirmation in production. + * + * @param string $warning + * @param \Closure|bool|null $callback + * @return bool + */ + public function confirmToProceed($warning = 'Application In Production!', $callback = null) + { + if ($this->hasOption('force') && $this->option('force')) { + return true; + } + + $this->alert('The .env file already exists. Proceeding may overwrite some values!'); + + $confirmed = $this->confirm('Do you really wish to run this command?'); + + if (!$confirmed) { + $this->comment('Command Canceled!'); + + return false; + } + + return true; + } + /** * Get the full path of a config file * @param string $config @@ -96,6 +125,15 @@ protected function updateEnvFile(): void $env->set($dbEnvKey, config(join('.', [$config, 'connections', $default, $dbConfigKey]))); } } + + if ($config === 'mail' && $envKey === 'MAIL_MAILER') { + $default = config('mail.default'); + $mailConfig = $this->mailConfig()[$default] ?? []; + + foreach ($mailConfig as $mailEnvKey => $mailConfigKey) { + $env->set($mailEnvKey, config(join('.', [$config, 'mailers', $default, $mailConfigKey]))); + } + } } $env->addEmptyLine(); } @@ -126,6 +164,17 @@ protected function updateConfigFiles(): void } } } + if ($config === 'mail' && $envKey === 'MAIL_MAILER') { + foreach ($this->mailConfig() as $mailer => $keys) { + foreach ($keys as $mailEnvKey => $mailConfigKey) { + $path = sprintf('mailers.%s.%s', $mailer, $mailConfigKey); + $arrayFile->set( + $path, + $arrayFile->function('env', $this->getKeyValuePair($mailEnvKey, $config . '.' . $path)) + ); + } + } + } } $arrayFile->write(); } @@ -168,11 +217,6 @@ protected function config(): array ], 'mail' => [ 'MAIL_MAILER' => 'default', - 'MAIL_HOST' => 'host', - 'MAIL_PORT' => 'port', - 'MAIL_USERNAME' => 'username', - 'MAIL_PASSWORD' => 'password', - 'MAIL_ENCRYPTION' => 'encryption', ], 'cms' => [ 'ROUTES_CACHE' => 'enableRoutesCache', @@ -215,4 +259,27 @@ protected function dbConfig(): array ], ]; } + + /** + * Returns a map of env keys to php config keys for mail configs + * @return array + */ + protected function mailConfig(): array + { + return [ + 'smtp' => [ + 'MAIL_ENCRYPTION' => 'encryption', + 'MAIL_HOST' => 'host', + 'MAIL_PASSWORD' => 'password', + 'MAIL_PORT' => 'port', + 'MAIL_USERNAME' => 'username', + ], + 'sendmail' => [ + 'MAIL_SENDMAIL_PATH' => 'path', + ], + 'log' => [ + 'MAIL_LOG_CHANNEL' => 'channel', + ], + ]; + } }