00f100 / fcphp-controller
此包最新版本(0.1.0)没有可用的许可证信息。
FcPhp 的抽象类 Controller
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 Controller 的抽象类
如何安装
Composer
$ composer require 00f100/fcphp-controller
或者在 composer.json 中添加
{ "require": { "00f100/fcphp-controller": "*" } }
如何使用
从 FcPhp Controller 扩展你的控制器,并通过构造方法添加你的服务。在调用服务后,使用 "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... });