Last active
          June 2, 2025 23:02 
        
      - 
      
 - 
        
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 hidden or 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 | |
| { | |
| Vite::useAggressivePrefetching(); | |
| Model::automaticallyEagerLoadRelationships(); | |
| URL::forceHttps(); | |
| Date::use(CarbonImmutable::class); | |
| DB::prohibitDestructiveCommands(app()->isProduction()); | |
| Password::defaults(fn (): ?Password => app()->isProduction() ? Password::min(12)->max(255)->uncompromised() : null); | |
| Model::shouldBeStrict(); | |
| Model::unguard(); | |
| 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