PHP code example of takeoo / laravel-service-layer

1. Go to this page and download the library: Download takeoo/laravel-service-layer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

takeoo / laravel-service-layer example snippets



//Example.php


namespace  My\Service\Namespace;


use Takeoo\Service;

class MyService extends Service
{
// your code 
}



//Example.php


namespace  My\Service\Namespace;


use Takeoo\Service\Traits;

class MyService 
{
 use Service;
// your code 
}



'services' => [
  'Example' => \My\Service\Namespace\Example::class,
]


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


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


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

bash
   php artisan vendor:publish