Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/00f100/fcphp-dispach
Packge to dispach request to FcPhp Controller
https://github.com/00f100/fcphp-dispach
dispach fcphp fcphp-controller fcphp-di fcphp-dispach php7 php72
Last synced: 25 days ago
JSON representation
Packge to dispach request to FcPhp Controller
- Host: GitHub
- URL: https://github.com/00f100/fcphp-dispach
- Owner: 00F100
- License: mit
- Created: 2018-08-12T22:16:03.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-13T02:06:01.000Z (about 6 years ago)
- Last Synced: 2024-03-23T02:46:30.494Z (8 months ago)
- Topics: dispach, fcphp, fcphp-controller, fcphp-di, fcphp-dispach, php7, php72
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FcPhp Dispach
Package to dispach request to controller. Uses [FcPhp Di](https://github.com/00f100/fcphp-di) to find Controller instance.
[![Build Status](https://travis-ci.org/00F100/fcphp-dispach.svg?branch=master)](https://travis-ci.org/00F100/fcphp-dispach) [![codecov](https://codecov.io/gh/00F100/fcphp-dispach/branch/master/graph/badge.svg)](https://codecov.io/gh/00F100/fcphp-dispach)
[![PHP Version](https://img.shields.io/packagist/php-v/00f100/fcphp-dispach.svg)](https://packagist.org/packages/00F100/fcphp-dispach) [![Packagist Version](https://img.shields.io/packagist/v/00f100/fcphp-dispach.svg)](https://packagist.org/packages/00F100/fcphp-dispach) [![Total Downloads](https://poser.pugx.org/00F100/fcphp-dispach/downloads)](https://packagist.org/packages/00F100/fcphp-dispach)
## How to install
Composer:
```sh
$ composer require 00f100/fcphp-dispach
```or add in composer.json
```json
{
"require": {
"00f100/fcphp-dispach": "*"
}
}
```## How to use
### Configure Dependency Injection with [FcPhp Di](https://github.com/00f100/fcphp-di)
```php
use FcPhp\Di\Facades\DiFacade;
use FcPhp\Controller\Controller;// Class example ...
class ExampleController extends Controller
{
public function findAll($foo, $bar)
{
return compact('foo', 'bar');
}
}
// Configure class into FcPhp Di
$di = DiFacade::getInstance();
$di->set('ExampleController', 'ExampleController');```
### Get instance and run Dispach
```php
use FcPhp\Dispach\Facades\DispachFacade;
// Init Dispach
$instance = DispachFacade::getInstance();/*
Return ExampleController->findAll('foo_value', 'bar_value'):
Array (
'foo' => 'foo_value',
'bar' => 'bar_value'
)
*/
print_r($instance->dispach('ExampleController@findAll', ['foo_value', 'bar_value']));
```