PHP code example of lowel / laravel-service-maker

1. Go to this page and download the library: Download lowel/laravel-service-maker 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/ */

    

lowel / laravel-service-maker example snippets


use App\Services\Payment\PaymentServiceInterface;
use App\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Facades\App;

// Using app() helper
$service = app(PaymentServiceInterface::class);
$repository = app(UserRepositoryInterface::class);

// Using App facade
$service = App::make(PaymentServiceInterface::class);

// Using constructor injection
public function __construct(
    PaymentServiceInterface $paymentService,
    UserRepositoryInterface $userRepository
) {
    // ...
}
bash
php artisan vendor:publish --provider="Lowel\\LaravelServiceMaker\\LaravelServiceMakerProvider" --tag="config"
bash
php artisan lowel:make:service Payment
bash
php artisan lowel:make:repository User --singleton

app/
├── Repositories/
│   ├── {RepositoryName}/
│   │   ├── {RepositoryName}Repository.php
│   │   ├── {RepositoryName}RepositoryInterface.php
│   │   └── {RepositoryName}RepositoryFactory.php
└── Services/
    ├── {ServiceName}/
    │   ├── {ServiceName}Service.php
    │   ├── {ServiceName}ServiceInterface.php
    │   └── {ServiceName}ServiceFactory.php
bash
php artisan vendor:publish --provider="Lowel\\LaravelServiceMaker\\LaravelServiceMakerProvider" --tag="config"