mirror of
https://github.com/coollabsio/coolify.git
synced 2026-09-24 23:40:16 -05:00
feat(core): New strict AppServiceProvider.php
This commit is contained in:
@@ -1,24 +1,114 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Facades\Vite;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
final class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
$this->configureHttps();
|
||||
$this->configurePasswordValidation();
|
||||
$this->configureCommands();
|
||||
$this->configureModels();
|
||||
$this->configureDates();
|
||||
$this->configureRequestExceptions();
|
||||
$this->configureVite();
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure HTTPS for production.
|
||||
*/
|
||||
private function configureHttps(): void
|
||||
{
|
||||
if (App::isProduction() && config('app.force_https')) {
|
||||
URL::forceScheme('https');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure password validation for production.
|
||||
*/
|
||||
private function configurePasswordValidation(): void
|
||||
{
|
||||
if (App::isProduction()) {
|
||||
Password::defaults(function () {
|
||||
return Password::min(12)
|
||||
->mixedCase()
|
||||
->letters()
|
||||
->numbers()
|
||||
->symbols()
|
||||
->uncompromised();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure commands for production.
|
||||
*/
|
||||
private function configureCommands(): void
|
||||
{
|
||||
if (App::isProduction()) {
|
||||
DB::prohibitDestructiveCommands();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure models.
|
||||
*/
|
||||
private function configureModels(): void
|
||||
{
|
||||
if (! App::isProduction()) {
|
||||
Model::preventLazyLoading();
|
||||
}
|
||||
Model::preventAccessingMissingAttributes();
|
||||
Model::unguard();
|
||||
|
||||
Relation::enforceMorphMap([
|
||||
// Add you polymorphic relations here. For example:
|
||||
// 'application' => \App\Models\Application::class,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure dates.
|
||||
*/
|
||||
private function configureDates(): void
|
||||
{
|
||||
Date::use(CarbonImmutable::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure request exceptions.
|
||||
*/
|
||||
private function configureRequestExceptions(): void
|
||||
{
|
||||
if (! App::isProduction()) {
|
||||
RequestException::dontTruncate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure Vite for better performance.
|
||||
*/
|
||||
private function configureVite(): void
|
||||
{
|
||||
Vite::useAggressivePrefetching();
|
||||
}
|
||||
}
|
||||
|
||||
+28
-4
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
@@ -13,7 +14,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
'name' => env('APP_NAME', 'Coolify'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -54,6 +55,30 @@ return [
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Port
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the port your application is running on. It can be
|
||||
| used to change what port the application is running on.
|
||||
|
|
||||
*/
|
||||
|
||||
'port' => env('APP_PORT', null),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Force HTTPS
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option can be used to force your application to use HTTPS instead
|
||||
| of HTTP, providing an additional layer of security for your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'force_https' => env('APP_FORCE_HTTPS', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
@@ -101,7 +126,7 @@ return [
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', env('APP_PREVIOUS_KEYS', ''))
|
||||
explode(',', env('APP_PREVIOUS_KEYS', '')),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -122,5 +147,4 @@ return [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user