I want to add service provider in laravel 11, but i am not sure how to add it using laravel 11. As previous version of laravel, it is added in config/app.php file, but in laravel 11 it needs to be added in packageServiceProvider file within providers folder. Below is my code, please tell me if i am wrong somewhere..
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class PaytmWalletServiceProvider extends ServiceProvider
{
/**
* All of the container bindings that should be registered.
*
* @var array
*/
public $bindings = [
ServerProvider::class => Anand\LaravelPaytmWallet\PaytmWalletServiceProvider::class,
];
/**
* Register services.
*/
public function register(): void
{
//
}
/**
* Bootstrap services.
*/
public function boot(): void
{
//
}
}
In previous version of Laravel, the providers were registered in config/app.php
file. But in Laravel 11.x most of the configurations are moved to /bootstrap
directory.
In Laravel 11.x and above, bootstrap/providers.php
file returns an array which contains all providers that will be registered in your application.
<?php
return [
App\Providers\AppServiceProvider::class,
...AllYourProvders
];