项目作者: 00F100

项目描述 :
Packge to dispach request to FcPhp Controller
高级语言: PHP
项目地址: git://github.com/00F100/fcphp-dispach.git
创建时间: 2018-08-12T22:16:03Z
项目社区:https://github.com/00F100/fcphp-dispach

开源协议:MIT License

下载


FcPhp Dispach

Package to dispach request to controller. Uses FcPhp Di to find Controller instance.

Build Status codecov

PHP Version Packagist Version Total Downloads

How to install

Composer:

  1. $ composer require 00f100/fcphp-dispach

or add in composer.json

  1. {
  2. "require": {
  3. "00f100/fcphp-dispach": "*"
  4. }
  5. }

How to use

Configure Dependency Injection with FcPhp Di

  1. use FcPhp\Di\Facades\DiFacade;
  2. use FcPhp\Controller\Controller;
  3. // Class example ...
  4. class ExampleController extends Controller
  5. {
  6. public function findAll($foo, $bar)
  7. {
  8. return compact('foo', 'bar');
  9. }
  10. }
  11. // Configure class into FcPhp Di
  12. $di = DiFacade::getInstance();
  13. $di->set('ExampleController', 'ExampleController');

Get instance and run Dispach

  1. use FcPhp\Dispach\Facades\DispachFacade;
  2. // Init Dispach
  3. $instance = DispachFacade::getInstance();
  4. /*
  5. Return ExampleController->findAll('foo_value', 'bar_value'):
  6. Array (
  7. 'foo' => 'foo_value',
  8. 'bar' => 'bar_value'
  9. )
  10. */
  11. print_r($instance->dispach('ExampleController@findAll', ['foo_value', 'bar_value']));