2017 © Pedro Peláez
 

library laravel-service-layer

Lightweight service layer for laravel application!

image

takeoo/laravel-service-layer

Lightweight service layer for laravel application!

  • Sunday, May 27, 2018
  • by TakeoO
  • Repository
  • 1 Watchers
  • 6 Stars
  • 99 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 14 % Grown

The README.md

Service Layer for laravel framework

Extra simple, lightweight service manager module for laravel app, (*1)

Installation

  • Require repository, (*2)

    composer require takeoo/laravel-service-layer
    
    • Add \Takeoo\Service\TakeooServiceServiceProvider::class to config/app.php "providers" array, (*3)

    • Run:, (*4)

    php artisan vendor:publish      
    

Usage

  • Create new service class (Example.php) anywhere in your project:

//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;, (*5)


//Example.php namespace My\Service\Namespace; use Takeoo\Service\Traits; class MyService { use Service; // your code }
  • when you created new service class, you have to register it:
    • go to config/service.php
    • add your service to "services" array:

'services' => [ 'Example' => \My\Service\Namespace\Example::class, ]
  • Add Service trait to your Controller.php class (if you extend it with all your controllers) or to every controller class in which you want to use Service layer

By default all services are created as singletons, if you want to create non singleton class, provided its alias in "service.non-singleton" array, (*6)

Code

In code you can call your service as:, (*7)


$service = $this->getService("Example");

if you want to use autocomplete (tested in JetBrains IDE) add PHPDoc above variable, (*8)


/** * @var \My\Service\Namespace\Example $serivce */ $service = $this->getService("Example");

or you can always create helper functions for your commonly used services e.g:, (*9)


/** * return \My\Service\Namespace\Example */ public function getExampleService() { return $this->getService("Example"); }

The Versions

27/05 2018

dev-master

9999999-dev

Lightweight service layer for laravel application!

  Sources   Download

The Requires

 

laravel service layer

19/03 2017

v0.2.2

0.2.2.0

Lightweight service layer for laravel application!

  Sources   Download

The Requires

 

laravel service layer

15/03 2017

v0.2.1

0.2.1.0

Lightweight service layer for laravel application!

  Sources   Download

The Requires

 

laravel service layer

15/03 2017

v0.2.0

0.2.0.0

Lightweight service layer for laravel application!

  Sources   Download

The Requires

 

laravel service layer

14/03 2017

v0.1.2

0.1.2.0

Package enables service layer in all laravel applications. Move business logic to where it belongs!

  Sources   Download

The Requires

 

laravel service layer