Package Data | |
---|---|
Maintainer Username: | TakeoO |
Package Create Date: | 2017-03-14 |
Package Last Update: | 2020-11-27 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-12-19 03:17:21 |
Package Statistics | |
---|---|
Total Downloads: | 255 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 15 |
Total Watchers: | 2 |
Total Forks: | 3 |
Total Open Issues: | 1 |
Extra simple, lightweight service manager module for laravel app
composer require takeoo/laravel-service-layer
Add \Takeoo\Service\TakeooServiceServiceProvider::class to config/app.php "providers" array
Run:
php artisan vendor:publish
//Example.php
namespace My\Service\Namespace;
use Takeoo\Service;
class MyService extends Service
{
// your code
}
or if you do not want to extend Service.php just use Service trait;
//Example.php
namespace My\Service\Namespace;
use Takeoo\Service\Traits;
class MyService
{
use Service;
// your code
}
'services' => [
'Example' => \My\Service\Namespace\Example::class,
]
By default all services are created as singletons, if you want to create non singleton class, provided its alias in "service.non-singleton" array
In code you can call your service as:
$service = $this->getService("Example");
if you want to use autocomplete (tested in JetBrains IDE) add PHPDoc above variable
/**
* @var \My\Service\Namespace\Example $serivce
*/
$service = $this->getService("Example");
or you can always create helper functions for your commonly used services e.g:
/**
* return \My\Service\Namespace\Example
*/
public function getExampleService()
{
return $this->getService("Example");
}