Last active
April 15, 2025 14:42
-
-
Save sawirricardo/6e58e1bf528068a88f975a296a7e0e66 to your computer and use it in GitHub Desktop.
Better defaults for your laravel projects, inspired by Nuno Maduro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Carbon\CarbonImmutable; | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Support\Facades\Date; | |
use Illuminate\Support\Facades\DB; | |
use Illuminate\Support\Facades\Http; | |
use Illuminate\Support\Facades\URL; | |
use Illuminate\Support\Facades\Vite; | |
use Illuminate\Support\ServiceProvider; | |
use Illuminate\Support\Sleep; | |
use Illuminate\Validation\Rules\Password; | |
class AppServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Register any application services. | |
*/ | |
public function register(): void | |
{ | |
// | |
} | |
/** | |
* Bootstrap any application services. | |
*/ | |
public function boot(): void | |
{ | |
Model::unguard(); | |
Model::shouldBeStrict(); | |
Model::automaticallyEagerLoadRelationships(); | |
Vite::useAggressivePrefetching(); | |
URL::forceHttps(); | |
DB::prohibitDestructiveCommands(app()->isProduction()); | |
Date::use(CarbonImmutable::class); | |
Password::defaults(fn (): ?Password => app()->isProduction() ? Password::min(12)->max(255)->uncompromised() : null); | |
if (app()->runningUnitTests()) { | |
Http::preventStrayRequests(); | |
Sleep::fake(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment