Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/00f100/fcphp-controller
Abstract class to FcPhp Controllers
https://github.com/00f100/fcphp-controller
controller fcphp fcphp-controller php7 php72
Last synced: about 1 month ago
JSON representation
Abstract class to FcPhp Controllers
- Host: GitHub
- URL: https://github.com/00f100/fcphp-controller
- Owner: 00F100
- License: mit
- Created: 2018-08-13T00:49:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-17T03:05:27.000Z (over 6 years ago)
- Last Synced: 2024-11-18T02:26:46.659Z (about 2 months ago)
- Topics: controller, fcphp, fcphp-controller, php7, php72
- Language: PHP
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FcPhp Controller
Abstract class to Controller FcPhp
[![Build Status](https://travis-ci.org/00F100/fcphp-controller.svg?branch=master)](https://travis-ci.org/00F100/fcphp-controller) [![codecov](https://codecov.io/gh/00F100/fcphp-controller/branch/master/graph/badge.svg)](https://codecov.io/gh/00F100/fcphp-controller)
[![PHP Version](https://img.shields.io/packagist/php-v/00f100/fcphp-controller.svg)](https://packagist.org/packages/00F100/fcphp-controller) [![Packagist Version](https://img.shields.io/packagist/v/00f100/fcphp-controller.svg)](https://packagist.org/packages/00F100/fcphp-controller) [![Total Downloads](https://poser.pugx.org/00F100/fcphp-controller/downloads)](https://packagist.org/packages/00F100/fcphp-controller)
## How to install
Composer:
```sh
$ composer require 00f100/fcphp-controller
```or add in composer.json
```json
{
"require": {
"00f100/fcphp-controller": "*"
}
}
```## How to use
Extends your controller from [FcPhp Controller](https://github.com/00F100/fcphp-controller) and add your services into Controller using contruct method. After call to service using "getService()" method.
```php
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();
}
}
}```
## Controller Callback
```php
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...
});
```