00f100 / fcphp-service
There is no license information available for the latest version (0.1.1) of this package.
Package to manipulate services of application
0.1.1
2018-08-17 03:06 UTC
Requires
- php: >=7.2
Requires (Dev)
- 00f100/phpdbug: *
- phpunit/phpunit: 6.*
This package is auto-updated.
Last update: 2026-02-18 09:05:41 UTC
README
Abstract class to Service FcPhp
How to install
Composer:
$ composer require 00f100/fcphp-service
or add in composer.json
{
"require": {
"00f100/fcphp-service": "*"
}
}
How to use
Extends your service from FcPhp Service and add your repositories into Service using contruct method. After call to repository using "getRepository()" method.
namespace Example { use FcPhp\Service\Service; class ExampleService extends Service { public function __construct($userRepository, $profileRepository, $addressRepository) { $this->setRepository('user', $userRepository); $this->setRepository('profile', $profileRepository); $this->setRepository('address', $addressRepository); } public function findUsers() { return $this->getRepository('user')->findAll(); } public function findProfiles() { return $this->getRepository('profile')->findAll(); } public function findAddresses() { return $this->getRepository('address')->findAll(); } } }
Service Callback
use Example\ExampleService; $instance = new ExampleService(); // Callback on find service using "getService()"... $instance->callback('callbackRepository', function(string $repository, $instance) { // Your code here... });