Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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...

});

```