This package makes it easy to define singletons for the service container with just an implementation of a single interface.
You can install the package via composer:
composer require sikhlana/laravel-singleton
If you need to install the service provider manually:
// config/app.php
'providers' => [
...
Sikhlana\Singleton\SingletonServiceProvider::class,
],
All you have to do is make the class you want to use as a singleton implement the Sikhlana\Singleton\Singleton
interface:
use Sikhlana\Singleton\Singleton;
class MySingletonClass implements Singleton
{
...
}
And voila! You're done.
You can do unit tests by running:
vendor/bin/phpunit
Please see CHANGELOG for more information what has changed recently.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.