Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 2.2 KB

README.md

File metadata and controls

53 lines (41 loc) · 2.2 KB

Laravel Service Pattern

A minimal package to implement Service Design Pattern in Laravel. It will also bind interface and service class in the AppServiceProvider.php.

Latest Stable Version Total Downloads License PHP Version Require

Installation

composer require haroon-mahmood-4276/laravel-service-pattern

Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

If laravel's auto-discovery doesn't work, add following lines in providers array in config/app.php

/*
* Package Service Providers...
*/
...

HaroonMahmood4276\LaravelServicePattern\PatternServiceProvider::class,
...

Command

This command is used to implement Service Design Pattern in Laravel Project. It make a service class with interface. {--do-not-bind}(optional) is used to prevent service and interface binding in AppServiceProvider.php. {--without-interface}(optional) prevents the interface class to be created by this command.

php artisan make:service {name} {--do-not-bind} {--without-interface}

How to use

protected $myInterface;

public function __construct(MyInterface $myInterface)
{
  $this->myInterface = $myInterface;
}

Want to contribute

  • Fork this repo.
  • Contribute in it.
  • Open a pull request.

Security Vulnerabilities

If you discover a security vulnerability within package, please send an e-mail to Haroon Mahmood via [email protected]. All security vulnerabilities will be promptly addressed.

License

This package is open-sourced software licensed under the MIT license.