From 8b8ee17246568271baaf891cabf87683ef2f4178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Thu, 12 Nov 2026 10:07:33 +0100 Subject: [PATCH] refactor: restore laravel 13 default configs for cache, filesystems and session --- config/cache.php | 130 +++++++++++++++++ config/filesystems.php | 39 ++--- config/session.php | 316 ++++++++++++++++++++++------------------- 3 files changed, 312 insertions(+), 173 deletions(-) create mode 100644 config/cache.php diff --git a/config/cache.php b/config/cache.php new file mode 100644 index 00000000..3e971d5f --- /dev/null +++ b/config/cache.php @@ -0,0 +1,130 @@ + env('CACHE_STORE', 'database'), + + /* + |-------------------------------------------------------------------------- + | Cache Stores + |-------------------------------------------------------------------------- + | + | Here you may define all of the cache "stores" for your application as + | well as their drivers. You may even define multiple stores for the + | same cache driver to group types of items stored in your caches. + | + | Supported drivers: "array", "database", "file", "memcached", + | "redis", "dynamodb", "storage", "octane", + | "session", "failover", "null" + | + */ + + 'stores' => [ + + 'array' => [ + 'driver' => 'array', + 'serialize' => false, + ], + + 'session' => [ + 'driver' => 'session', + 'key' => env('SESSION_CACHE_KEY', '_cache'), + ], + + 'database' => [ + 'driver' => 'database', + 'connection' => env('DB_CACHE_CONNECTION'), + 'table' => env('DB_CACHE_TABLE', 'cache'), + 'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'), + 'lock_table' => env('DB_CACHE_LOCK_TABLE'), + ], + + 'file' => [ + 'driver' => 'file', + 'path' => storage_path('framework/cache/data'), + 'lock_path' => storage_path('framework/cache/data'), + ], + + 'storage' => [ + 'driver' => 'storage', + 'disk' => env('CACHE_STORAGE_DISK'), + 'path' => env('CACHE_STORAGE_PATH', 'framework/cache/data'), + ], + + 'memcached' => [ + 'driver' => 'memcached', + 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), + 'sasl' => [ + env('MEMCACHED_USERNAME'), + env('MEMCACHED_PASSWORD'), + ], + 'options' => [ + // Memcached::OPT_CONNECT_TIMEOUT => 2000, + ], + 'servers' => [ + [ + 'host' => env('MEMCACHED_HOST', '127.0.0.1'), + 'port' => env('MEMCACHED_PORT', 11211), + 'weight' => 100, + ], + ], + ], + + 'redis' => [ + 'driver' => 'redis', + 'connection' => env('REDIS_CACHE_CONNECTION', 'cache'), + 'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'), + ], + + 'dynamodb' => [ + 'driver' => 'dynamodb', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'endpoint' => env('DYNAMODB_ENDPOINT'), + ], + + 'octane' => [ + 'driver' => 'octane', + ], + + 'failover' => [ + 'driver' => 'failover', + 'stores' => [ + 'database', + 'array', + ], + ], + + ], + + /* + |-------------------------------------------------------------------------- + | Cache Key Prefix + |-------------------------------------------------------------------------- + | + | When utilizing the APC, database, memcached, Redis, and DynamoDB cache + | stores, there might be other applications using the same cache. For + | that reason, you may prefix every cache key to avoid collisions. + | + */ + + 'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')) . '-cache-'), + +]; diff --git a/config/filesystems.php b/config/filesystems.php index a4956fe7..4e5aea19 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -15,7 +15,7 @@ return [ | */ - 'default' => env('FILESYSTEM_DISK') ?: 'local', + 'default' => env('FILESYSTEM_DISK', 'local'), /* |-------------------------------------------------------------------------- @@ -32,22 +32,23 @@ return [ 'disks' => [ + 'local' => [ + 'driver' => 'local', + 'root' => storage_path('app/private'), + 'serve' => true, + 'throw' => false, + 'report' => false, + ], + 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), - 'url' => rtrim((string) env('APP_URL', 'http://localhost'), '/') . '/storage', + 'url' => rtrim((string) env('APP_URL'), '/') . '/storage', 'visibility' => 'public', 'throw' => false, 'report' => false, ], - 'private' => [ - 'driver' => 'local', - 'root' => storage_path('app/private'), - 'visibility' => 'private', - 'throw' => false, - ], - 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), @@ -61,26 +62,6 @@ return [ 'report' => false, ], - 'inco' => [ - 'driver' => 'local', - 'root' => storage_path('inco'), - 'visibility' => 'private', - 'throw' => true, - ], - - 'employees' => [ - 'driver' => 'local', - 'root' => storage_path('salaries'), - 'visibility' => 'private', - 'throw' => true, - ], - - 'regate' => [ - 'driver' => 'local', - 'root' => storage_path('orders/in'), - 'visibility' => 'private', - 'throw' => true, - ], ], /* diff --git a/config/session.php b/config/session.php index dcd58731..5db08ecc 100644 --- a/config/session.php +++ b/config/session.php @@ -6,186 +6,214 @@ use Illuminate\Support\Str; return [ - /** - * |-------------------------------------------------------------------------- - * | Default Session Driver - * |-------------------------------------------------------------------------- - * | - * | This option controls the default session "driver" that will be used on - * | requests. By default, we will use the lightweight native driver but - * | you may specify any of the other wonderful drivers provided here. - * | - * | Supported: "file", "cookie", "database", "apc", - * | "memcached", "redis", "dynamodb", "array" - * | + /* + |-------------------------------------------------------------------------- + | Default Session Driver + |-------------------------------------------------------------------------- + | + | This option determines the default session driver that is utilized for + | incoming requests. Laravel supports a variety of storage options to + | persist session data. Database storage is a great default choice. + | + | Supported: "file", "cookie", "database", "memcached", + | "redis", "dynamodb", "array" + | */ - 'driver' => env('SESSION_DRIVER') ?: 'file', - /** - * |-------------------------------------------------------------------------- - * | Session Lifetime - * |-------------------------------------------------------------------------- - * | - * | Here you may specify the number of minutes that you wish the session - * | to be allowed to remain idle before it expires. If you want them - * | to immediately expire on the browser closing, set that option. - * | + 'driver' => env('SESSION_DRIVER', 'database'), + + /* + |-------------------------------------------------------------------------- + | Session Lifetime + |-------------------------------------------------------------------------- + | + | Here you may specify the number of minutes that you wish the session + | to be allowed to remain idle before it expires. If you want them + | to expire immediately when the browser is closed then you may + | indicate that via the expire_on_close configuration option. + | */ - 'lifetime' => env('SESSION_LIFETIME', 120), - 'expire_on_close' => false, + 'lifetime' => (int) env('SESSION_LIFETIME', 120), - /** - * |-------------------------------------------------------------------------- - * | Session Encryption - * |-------------------------------------------------------------------------- - * | - * | This option allows you to easily specify that all of your session data - * | should be encrypted before it is stored. All encryption will be run - * | automatically by Laravel and you can use the Session like normal. - * | + 'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false), + + /* + |-------------------------------------------------------------------------- + | Session Encryption + |-------------------------------------------------------------------------- + | + | This option allows you to easily specify that all of your session data + | should be encrypted before it's stored. All encryption is performed + | automatically by Laravel and you may use the session like normal. + | */ - 'encrypt' => false, - /** - * |-------------------------------------------------------------------------- - * | Session File Location - * |-------------------------------------------------------------------------- - * | - * | When using the native session driver, we need a location where session - * | files may be stored. A default has been set for you but a different - * | location may be specified. This is only needed for file sessions. - * | + 'encrypt' => env('SESSION_ENCRYPT', false), + + /* + |-------------------------------------------------------------------------- + | Session File Location + |-------------------------------------------------------------------------- + | + | When utilizing the "file" session driver, the session files are placed + | on disk. The default storage location is defined here; however, you + | are free to provide another location where they should be stored. + | */ + 'files' => storage_path('framework/sessions'), - /** - * |-------------------------------------------------------------------------- - * | Session Database Connection - * |-------------------------------------------------------------------------- - * | - * | When using the "database" or "redis" session drivers, you may specify a - * | connection that should be used to manage these sessions. This should - * | correspond to a connection in your database configuration options. - * | + /* + |-------------------------------------------------------------------------- + | Session Database Connection + |-------------------------------------------------------------------------- + | + | When using the "database" or "redis" session drivers, you may specify a + | connection that should be used to manage these sessions. This should + | correspond to a connection in your database configuration options. + | */ + 'connection' => env('SESSION_CONNECTION'), - 'prefix' => env('SESSION_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_session'), - - /** - * |-------------------------------------------------------------------------- - * | Session Database Table - * |-------------------------------------------------------------------------- - * | - * | When using the "database" session driver, you may specify the table we - * | should use to manage the sessions. Of course, a sensible default is - * | provided for you; however, you are free to change this as needed. - * | + /* + |-------------------------------------------------------------------------- + | Session Database Table + |-------------------------------------------------------------------------- + | + | When using the "database" session driver, you may specify the table to + | be used to store sessions. Of course, a sensible default is defined + | for you; however, you're welcome to change this to another table. + | */ - 'table' => 'sessions', - /** - * |-------------------------------------------------------------------------- - * | Session Cache Store - * |-------------------------------------------------------------------------- - * | - * | While using one of the framework's cache driven session backends you may - * | list a cache store that should be used for these sessions. This value - * | must match with one of the application's configured cache "stores". - * | - * | Affects: "apc", "dynamodb", "memcached", "redis" - * | + 'table' => env('SESSION_TABLE', 'sessions'), + + /* + |-------------------------------------------------------------------------- + | Session Cache Store + |-------------------------------------------------------------------------- + | + | When using one of the framework's cache driven session backends, you may + | define the cache store which should be used to store the session data + | between requests. This must match one of your defined cache stores. + | + | Affects: "dynamodb", "memcached", "redis" + | */ + 'store' => env('SESSION_STORE'), - /** - * |-------------------------------------------------------------------------- - * | Session Sweeping Lottery - * |-------------------------------------------------------------------------- - * | - * | Some session drivers must manually sweep their storage location to get - * | rid of old sessions from storage. Here are the chances that it will - * | happen on a given request. By default, the odds are 2 out of 100. - * | + /* + |-------------------------------------------------------------------------- + | Session Sweeping Lottery + |-------------------------------------------------------------------------- + | + | Some session drivers must manually sweep their storage location to get + | rid of old sessions from storage. Here are the chances that it will + | happen on a given request. By default, the odds are 2 out of 100. + | */ + 'lottery' => [2, 100], - /** - * |-------------------------------------------------------------------------- - * | Session Cookie Name - * |-------------------------------------------------------------------------- - * | - * | Here you may change the name of the cookie used to identify a session - * | instance by ID. The name specified here will get used every time a - * | new session cookie is created by the framework for every driver. - * | + /* + |-------------------------------------------------------------------------- + | Session Cookie Name + |-------------------------------------------------------------------------- + | + | Here you may change the name of the session cookie that is created by + | the framework. Typically, you should not need to change this value + | since doing so does not grant a meaningful security improvement. + | */ + 'cookie' => env( 'SESSION_COOKIE', - Str::slug(env('APP_NAME', 'laravel'), '_') . '_session' + Str::snake((string) env('APP_NAME', 'laravel')) . '_session' ), - /** - * |-------------------------------------------------------------------------- - * | Session Cookie Path - * |-------------------------------------------------------------------------- - * | - * | The session cookie path determines the path for which the cookie will - * | be regarded as available. Typically, this will be the root path of - * | your application but you are free to change this when necessary. - * | + /* + |-------------------------------------------------------------------------- + | Session Cookie Path + |-------------------------------------------------------------------------- + | + | The session cookie path determines the path for which the cookie will + | be regarded as available. Typically, this will be the root path of + | your application, but you're free to change this when necessary. + | */ - 'path' => '/', - /** - * |-------------------------------------------------------------------------- - * | Session Cookie Domain - * |-------------------------------------------------------------------------- - * | - * | Here you may change the domain of the cookie used to identify a session - * | in your application. This will determine which domains the cookie is - * | available to in your application. A sensible default has been set. - * | + 'path' => env('SESSION_PATH', '/'), + + /* + |-------------------------------------------------------------------------- + | Session Cookie Domain + |-------------------------------------------------------------------------- + | + | This value determines the domain and subdomains the session cookie is + | available to. By default, the cookie will be available to the root + | domain and all subdomains. Typically, this shouldn't be changed. + | */ + 'domain' => env('SESSION_DOMAIN'), - /** - * |-------------------------------------------------------------------------- - * | HTTPS Only Cookies - * |-------------------------------------------------------------------------- - * | - * | By setting this option to true, session cookies will only be sent back - * | to the server if the browser has a HTTPS connection. This will keep - * | the cookie from being sent to you when it can't be done securely. - * | + /* + |-------------------------------------------------------------------------- + | HTTPS Only Cookies + |-------------------------------------------------------------------------- + | + | By setting this option to true, session cookies will only be sent back + | to the server if the browser has a HTTPS connection. This will keep + | the cookie from being sent to you when it can't be done securely. + | */ + 'secure' => env('SESSION_SECURE_COOKIE'), - /** - * |-------------------------------------------------------------------------- - * | HTTP Access Only - * |-------------------------------------------------------------------------- - * | - * | Setting this value to true will prevent JavaScript from accessing the - * | value of the cookie and the cookie will only be accessible through - * | the HTTP protocol. You are free to modify this option if needed. - * | + /* + |-------------------------------------------------------------------------- + | HTTP Access Only + |-------------------------------------------------------------------------- + | + | Setting this value to true will prevent JavaScript from accessing the + | value of the cookie and the cookie will only be accessible through + | the HTTP protocol. It's unlikely you should disable this option. + | */ - 'http_only' => true, - /** - * |-------------------------------------------------------------------------- - * | Same-Site Cookies - * |-------------------------------------------------------------------------- - * | - * | This option determines how your cookies behave when cross-site requests - * | take place, and can be used to mitigate CSRF attacks. By default, we - * | will set this value to "lax" since this is a secure default value. - * | - * | Supported: "lax", "strict", "none", null - * | + 'http_only' => env('SESSION_HTTP_ONLY', true), + + /* + |-------------------------------------------------------------------------- + | Same-Site Cookies + |-------------------------------------------------------------------------- + | + | This option determines how your cookies behave when cross-site requests + | take place, and can be used to mitigate CSRF attacks. By default, we + | will set this value to "lax" to permit secure cross-site requests. + | + | See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value + | + | Supported: "lax", "strict", "none", null + | */ - 'same_site' => 'lax', + + 'same_site' => env('SESSION_SAME_SITE', 'lax'), + + /* + |-------------------------------------------------------------------------- + | Partitioned Cookies + |-------------------------------------------------------------------------- + | + | Setting this value to true will tie the cookie to the top-level site for + | a cross-site context. Partitioned cookies are accepted by the browser + | when flagged "secure" and the Same-Site attribute is set to "none". + | + */ + + 'partitioned' => env('SESSION_PARTITIONED_COOKIE', false), ];