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
{
//
}
}
boostrap/providers.php
instead of config/app.php though the old style should still work – BloomingtonAnand\LaravelPaytmWallet
that is mentioned in your code (I am assuming that is the one you mean) supports Laravel package discovery so the service provider and aliases should be registered automatically by Laravel. You should not need to register it yourself. In fact most packages written for Laravel are written in a way that supports this. – BloomingtonPaytmWalletServiceProvider class
from provider folder and file? – Variola