From 80214c5e71ce9f91d795f83df6abedbdefe19463 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 30 Aug 2026 20:53:53 +0930 Subject: [PATCH] chore: uplift framework skeleton toward Laravel 12 defaults Modernize artisan and public/index.php to the streamlined bootstrap form, migrate factories/seeders autoload to PSR-4 (database/seeds -> seeders), and backfill missing env-driven config keys across app, session, database, queue, mail, logging, and cache. All changes are additive and preserve existing Pixelfed behavior and defaults. --- artisan | 49 ++-------- composer.json | 10 +- config/app.php | 96 ++++++------------- config/cache.php | 8 +- config/database.php | 6 ++ config/logging.php | 28 ++++-- config/mail.php | 1 + config/queue.php | 44 ++++++--- config/session.php | 16 ++-- .../{seeds => seeders}/DatabaseSeeder.php | 6 +- public/index.php | 61 ++---------- 11 files changed, 123 insertions(+), 202 deletions(-) rename database/{seeds => seeders}/DatabaseSeeder.php (76%) diff --git a/artisan b/artisan index 5c23e2e24..c35e31d6a 100644 --- a/artisan +++ b/artisan @@ -1,53 +1,18 @@ #!/usr/bin/env php make(Illuminate\Contracts\Console\Kernel::class); - -$status = $kernel->handle( - $input = new Symfony\Component\Console\Input\ArgvInput, - new Symfony\Component\Console\Output\ConsoleOutput -); - -/* -|-------------------------------------------------------------------------- -| Shutdown The Application -|-------------------------------------------------------------------------- -| -| Once Artisan has finished running, we will fire off the shutdown events -| so that any final work may be done by the application before we shut -| down the process. This is the last thing to happen to the request. -| -*/ - -$kernel->terminate($input, $status); +$status = $app->handleCommand(new ArgvInput); exit($status); diff --git a/composer.json b/composer.json index 184ffb399..25b1f5983 100644 --- a/composer.json +++ b/composer.json @@ -50,21 +50,21 @@ "require-dev": { "fakerphp/faker": "^1.23", "larastan/larastan": "^3.0", + "laravel/boost": "^2.7", "laravel/pint": "^1.13", "laravel/telescope": "^5.5", "mockery/mockery": "^1.6", "nunomaduro/collision": "^8.8", "pestphp/pest": "^4.0", "psalm/plugin-laravel": "^3", + "rector/rector": "^2.6", "vimeo/psalm": "^6.5" }, "autoload": { - "classmap": [ - "database/seeds", - "database/factories" - ], "psr-4": { - "App\\": "app/" + "App\\": "app/", + "Database\\Factories\\": "database/factories/", + "Database\\Seeders\\": "database/seeders/" }, "files": [ "app/helpers.php" diff --git a/config/app.php b/config/app.php index a6f5dbb1c..42c0cc558 100644 --- a/config/app.php +++ b/config/app.php @@ -1,39 +1,7 @@ 'AES-256-CBC', + 'previous_keys' => [ + ...array_filter( + explode(',', (string) env('APP_PREVIOUS_KEYS', '')) + ), + ], + + /* + |-------------------------------------------------------------------------- + | Maintenance Mode Driver + |-------------------------------------------------------------------------- + | + | These configuration options determine the driver used to determine and + | manage Laravel's "maintenance mode" status. The "cache" driver will + | allow maintenance mode to be controlled across multiple machines. + | + | Supported drivers: "file", "cache" + | + */ + + 'maintenance' => [ + 'driver' => env('APP_MAINTENANCE_DRIVER', 'file'), + 'store' => env('APP_MAINTENANCE_STORE', 'database'), + ], + 'short_description' => env('PF_SHORT_DESCRIPTION', 'Pixelfed is an image sharing platform, an ethical alternative to centralized platforms.'), 'description' => env('PF_DESCRIPTION', 'Pixelfed is an image sharing platform, an ethical alternative to centralized platforms.'), 'rules' => env('PF_RULES', null), @@ -165,42 +157,8 @@ return [ | */ - 'aliases' => [ - 'App' => App::class, - 'Artisan' => Artisan::class, - 'Auth' => Auth::class, - 'Blade' => Blade::class, - 'Broadcast' => Broadcast::class, - 'Bus' => Bus::class, - 'Cache' => Cache::class, - 'Config' => Config::class, - 'Cookie' => Cookie::class, - 'Crypt' => Crypt::class, - 'DB' => DB::class, - 'Event' => Event::class, - 'File' => File::class, - 'Gate' => Gate::class, - 'Hash' => Hash::class, - 'Lang' => Lang::class, - 'Log' => Log::class, - 'Mail' => Mail::class, - 'Notification' => Notification::class, - 'Password' => Password::class, - 'Queue' => Queue::class, - 'Redirect' => Redirect::class, - 'Redis' => Redis::class, - 'Request' => Request::class, - 'Response' => Response::class, - 'Route' => Route::class, - 'Schema' => Schema::class, - 'Session' => Session::class, - 'Storage' => Storage::class, - 'URL' => URL::class, - 'Validator' => Validator::class, - 'View' => View::class, - 'Str' => Str::class, - + 'aliases' => Facade::defaultAliases()->merge([ 'PrettyNumber' => PrettyNumber::class, - ], + ])->toArray(), ]; diff --git a/config/cache.php b/config/cache.php index 212623523..aa17afc6a 100644 --- a/config/cache.php +++ b/config/cache.php @@ -43,9 +43,9 @@ return [ 'database' => [ 'driver' => 'database', - 'table' => 'cache', - 'connection' => null, - 'lock_connection' => null, + 'table' => env('DB_CACHE_TABLE', 'cache'), + 'connection' => env('DB_CACHE_CONNECTION'), + 'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'), ], 'file' => [ @@ -75,7 +75,7 @@ return [ 'redis' => [ 'driver' => 'redis', - 'lock_connection' => 'default', + 'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'), 'client' => env('REDIS_CLIENT', 'predis'), 'default' => [ diff --git a/config/database.php b/config/database.php index 89ce75525..e2131ccb4 100644 --- a/config/database.php +++ b/config/database.php @@ -54,6 +54,9 @@ return [ 'prefix' => '', 'strict' => env('DB_STRICT', false), 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ + (class_exists('Pdo\Mysql') ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'), + ]) : [], 'dump' => [ 'use_single_transaction', 'skip_lock_tables', @@ -138,6 +141,7 @@ return [ 'scheme' => env('REDIS_SCHEME', 'tcp'), 'path' => env('REDIS_PATH'), 'host' => env('REDIS_HOST', '127.0.0.1'), + 'username' => env('REDIS_USERNAME', null), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), 'database' => env('REDIS_DATABASE', 0), @@ -147,6 +151,7 @@ return [ 'scheme' => env('REDIS_SCHEME', 'tcp'), 'path' => env('REDIS_PATH'), 'host' => env('REDIS_HOST', '127.0.0.1'), + 'username' => env('REDIS_USERNAME', null), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), 'database' => env('REDIS_DATABASE_SESSION', 1), @@ -156,6 +161,7 @@ return [ 'scheme' => env('REDIS_SCHEME', 'tcp'), 'path' => env('REDIS_PATH'), 'host' => env('REDIS_HOST', '127.0.0.1'), + 'username' => env('REDIS_USERNAME', null), 'password' => env('REDIS_PASSWORD', null), 'port' => env('REDIS_PORT', 6379), 'database' => env('REDIS_DATABASE_PULSE', 2), diff --git a/config/logging.php b/config/logging.php index 001bf2d10..451b4ccf3 100644 --- a/config/logging.php +++ b/config/logging.php @@ -18,6 +18,22 @@ return [ 'default' => env('LOG_CHANNEL', 'stack'), + /* + |-------------------------------------------------------------------------- + | Deprecations Log Channel + |-------------------------------------------------------------------------- + | + | This option controls the log channel that should be used to log warnings + | regarding deprecated PHP and library features. This allows you to get + | your application ready for upcoming major versions of dependencies. + | + */ + + 'deprecations' => [ + 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), + 'trace' => env('LOG_DEPRECATIONS_TRACE', false), + ], + /* |-------------------------------------------------------------------------- | Log Channels @@ -49,16 +65,16 @@ return [ 'daily' => [ 'driver' => 'daily', 'path' => storage_path('logs/laravel.log'), - 'level' => 'debug', - 'days' => 14, + 'level' => env('LOG_LEVEL', 'debug'), + 'days' => env('LOG_DAILY_DAYS', 14), ], 'slack' => [ 'driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), - 'username' => 'Laravel Log', - 'emoji' => ':boom:', - 'level' => 'critical', + 'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'), + 'emoji' => env('LOG_SLACK_EMOJI', ':boom:'), + 'level' => env('LOG_LEVEL', 'critical'), ], 'stderr' => [ @@ -78,7 +94,7 @@ return [ 'errorlog' => [ 'driver' => 'errorlog', - 'level' => 'debug', + 'level' => env('LOG_LEVEL', 'debug'), ], 'null' => [ diff --git a/config/mail.php b/config/mail.php index 175e9a79a..63af8ffcd 100644 --- a/config/mail.php +++ b/config/mail.php @@ -36,6 +36,7 @@ return [ 'mailers' => [ 'smtp' => [ 'transport' => 'smtp', + 'scheme' => env('MAIL_SCHEME'), 'url' => env('MAIL_URL'), 'host' => env('MAIL_HOST', '127.0.0.1'), 'port' => env('MAIL_PORT', 2525), diff --git a/config/queue.php b/config/queue.php index c3e6507b9..5ab37999a 100644 --- a/config/queue.php +++ b/config/queue.php @@ -36,38 +36,57 @@ return [ 'database' => [ 'driver' => 'database', - 'table' => 'jobs', - 'queue' => 'default', - 'retry_after' => 90, + 'connection' => env('DB_QUEUE_CONNECTION'), + 'table' => env('DB_QUEUE_TABLE', 'jobs'), + 'queue' => env('DB_QUEUE', 'default'), + 'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90), ], 'beanstalkd' => [ 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, + 'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'), + 'queue' => env('BEANSTALKD_QUEUE', 'default'), + 'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90), + 'block_for' => 0, ], 'sqs' => [ 'driver' => 'sqs', - 'key' => env('SQS_KEY', 'your-public-key'), - 'secret' => env('SQS_SECRET', 'your-secret-key'), + 'key' => env('SQS_KEY', env('AWS_ACCESS_KEY_ID', 'your-public-key')), + 'secret' => env('SQS_SECRET', env('AWS_SECRET_ACCESS_KEY', 'your-secret-key')), 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 'queue' => env('SQS_QUEUE', 'your-queue-name'), - 'region' => env('SQS_REGION', 'us-east-1'), + 'suffix' => env('SQS_SUFFIX'), + 'region' => env('SQS_REGION', env('AWS_DEFAULT_REGION', 'us-east-1')), ], 'redis' => [ 'driver' => 'redis', - 'connection' => 'default', - 'queue' => 'default', - 'retry_after' => 1800, + 'connection' => env('REDIS_QUEUE_CONNECTION', 'default'), + 'queue' => env('REDIS_QUEUE', 'default'), + 'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 1800), 'block_for' => null, 'after_commit' => true, ], ], + /* + |-------------------------------------------------------------------------- + | Job Batching + |-------------------------------------------------------------------------- + | + | The following options configure the database and table that store job + | batching information. These options can be updated to any database + | connection and table which has been defined by your application. + | + */ + + 'batching' => [ + 'database' => env('DB_CONNECTION', 'mysql'), + 'table' => 'job_batches', + ], + /* |-------------------------------------------------------------------------- | Failed Queue Jobs @@ -80,6 +99,7 @@ return [ */ 'failed' => [ + 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 'database' => env('DB_CONNECTION', 'mysql'), 'table' => 'failed_jobs', ], diff --git a/config/session.php b/config/session.php index d3e982bd4..e234c1117 100644 --- a/config/session.php +++ b/config/session.php @@ -31,7 +31,7 @@ return [ 'lifetime' => env('SESSION_LIFETIME', 86400), - 'expire_on_close' => false, + 'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false), /* |-------------------------------------------------------------------------- @@ -44,7 +44,7 @@ return [ | */ - 'encrypt' => false, + 'encrypt' => env('SESSION_ENCRYPT', false), /* |-------------------------------------------------------------------------- @@ -83,7 +83,7 @@ return [ | */ - 'table' => 'sessions', + 'table' => env('SESSION_TABLE', 'sessions'), /* |-------------------------------------------------------------------------- @@ -122,7 +122,7 @@ return [ | */ - 'cookie' => 'pxfs', + 'cookie' => env('SESSION_COOKIE', 'pxfs'), /* |-------------------------------------------------------------------------- @@ -135,7 +135,7 @@ return [ | */ - 'path' => '/', + 'path' => env('SESSION_PATH', '/'), /* |-------------------------------------------------------------------------- @@ -174,7 +174,7 @@ return [ | */ - 'http_only' => true, + 'http_only' => env('SESSION_HTTP_ONLY', true), /* |-------------------------------------------------------------------------- @@ -189,7 +189,7 @@ return [ | */ - 'same_site' => env('SESSION_SAME_SITE_COOKIES', 'lax'), + 'same_site' => env('SESSION_SAME_SITE_COOKIES', env('SESSION_SAME_SITE', 'lax')), /* |-------------------------------------------------------------------------- @@ -202,6 +202,6 @@ return [ | */ - 'partitioned' => false, + 'partitioned' => env('SESSION_PARTITIONED_COOKIE', false), ]; diff --git a/database/seeds/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php similarity index 76% rename from database/seeds/DatabaseSeeder.php rename to database/seeders/DatabaseSeeder.php index 91cb6d1c2..bef7c2c29 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -1,15 +1,15 @@ call(UsersTableSeeder::class); } diff --git a/public/index.php b/public/index.php index 34614ee2c..ee8f07e99 100644 --- a/public/index.php +++ b/public/index.php @@ -1,65 +1,20 @@ - */ define('LARAVEL_START', microtime(true)); -if (file_exists(__DIR__.'/../storage/framework/maintenance.php')) { - require __DIR__.'/../storage/framework/maintenance.php'; +// Determine if the application is in maintenance mode... +if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) { + require $maintenance; } -/* -|-------------------------------------------------------------------------- -| Register The Auto Loader -|-------------------------------------------------------------------------- -| -| Composer provides a convenient, automatically generated class loader for -| our application. We just need to utilize it! We'll simply require it -| into the script here so that we don't have to worry about manual -| loading any of our classes later on. It feels great to relax. -| -*/ - +// Register the Composer autoloader... require __DIR__.'/../vendor/autoload.php'; -/* -|-------------------------------------------------------------------------- -| Turn On The Lights -|-------------------------------------------------------------------------- -| -| We need to illuminate PHP development, so let us turn on the lights. -| This bootstraps the framework and gets it ready for use, then it -| will load up this application so that we can run it and send -| the responses back to the browser and delight our users. -| -*/ - +// Bootstrap Laravel and handle the request... +/** @var Application $app */ $app = require_once __DIR__.'/../bootstrap/app.php'; -/* -|-------------------------------------------------------------------------- -| Run The Application -|-------------------------------------------------------------------------- -| -| Once we have the application, we can handle the incoming request -| through the kernel, and send the associated response back to -| the client's browser allowing them to enjoy the creative -| and wonderful application we have prepared for them. -| -*/ - -$kernel = $app->make(Kernel::class); - -$response = $kernel->handle( - $request = Request::capture() -); - -$response->send(); - -$kernel->terminate($request, $response); +$app->handleRequest(Request::capture());