Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
<?php // app/Providers/AppServiceProvider.php namespace App\Providers; use App\Contracts\PaymentGateway; use App\Services\StripePaymentGateway; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider { public function register(): void { // Bind the interface to a concrete implementation $this->app->bind(PaymentGateway::class, function ($app) { return new StripePaymentGateway( config('services.stripe.secret') ); }); // Register a singleton (resolved only once) $this->app->singleton('analytics', function ($app) { return new \App\Services\AnalyticsService( config('services.analytics.key') ); }); } public function boot(): void { // Actions run after all providers are registered \Illuminate\Pagination\Paginator::useBootstrapFive(); } }
Result
Open