00f100 / fcphp-service
该包最新版本(0.1.1)没有提供许可证信息。
处理应用程序服务的包
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: 2024-09-18 06:23:08 UTC
README
FcPhp服务的抽象类
如何安装
Composer
$ composer require 00f100/fcphp-service
或者在composer.json中添加
{ "require": { "00f100/fcphp-service": "*" } }
如何使用
从FcPhp Service扩展您的服务,并使用构造方法将您的存储库添加到服务中。调用“getRepository()”方法后使用存储库。
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(); } } }
服务回调
use Example\ExampleService; $instance = new ExampleService(); // Callback on find service using "getService()"... $instance->callback('callbackRepository', function(string $repository, $instance) { // Your code here... });