sikhlana / laravel-singleton
A simple package to automatically mark a class as singleton.
Installs: 5 599
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.0|^7.3
- laravel/framework: >=5.8
Requires (Dev)
- orchestra/testbench: >=3.8
README
This package makes it easy to define singletons for the service container with just an implementation of a single interface.
Contents
Installation
You can install the package via composer:
composer require sikhlana/laravel-singleton
If your Laravel version is lower than 5.5 you need to install the service provider:
// config/app.php 'providers' => [ ... Sikhlana\Singleton\SingletonServiceProvider::class, ],
Usage
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 don't have to declare it manually via service providers or manual coding.
Testing
You can do unit tests by running:
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Security
If you discover any security related issues, please email xoxo@saifmahmud.name instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.