00f100 / fcphp-controller
此软件包最新版本(0.1.0)没有提供许可证信息。
FcPhp的抽象控制器类
0.1.0
2018-08-13 01:53 UTC
Requires
- php: >=7.2
Requires (Dev)
- 00f100/phpdbug: *
- phpunit/phpunit: 6.*
This package is auto-updated.
Last update: 2024-09-18 06:09:32 UTC
README
控制器FcPhp的抽象类
如何安装
Composer
$ composer require 00f100/fcphp-controller
或在composer.json中添加
{ "require": { "00f100/fcphp-controller": "*" } }
如何使用
从FcPhp 控制器扩展你的控制器,并使用构造方法将你的服务添加到控制器中。之后,使用"getService()"方法调用服务。
namespace Example { use FcPhp\Controller\Controller; class ExampleController extends Controller { public function __construct($userService, $profileService, $addressService) { $this->setService('user', $userService); $this->setService('profile', $profileService); $this->setService('address', $addressService); } public function findUsers() { return $this->getService('user')->findAll(); } public function findProfiles() { return $this->getService('profile')->findAll(); } public function findAddresses() { return $this->getService('address')->findAll(); } } }
控制器回调
use Example\ExampleController; $instance = new ExampleController(UserService(), ProfileService(), AddressService()); // Callback on find service using "getService()"... $instance->callback('callbackService', function(string $service, $instance) { // Your code here... });