2017 © Pedro Peláez
 

library fcontroller

FController is a container for controllers/modules.

image

othercode/fcontroller

FController is a container for controllers/modules.

  • Saturday, October 7, 2017
  • by othercode
  • Repository
  • 1 Watchers
  • 0 Stars
  • 51 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

FController

Build Status Latest Stable Version License, (*1)

FController is a container for controllers/modules. This package allow us to register several controllers/modules that can be called in a simply way from a common entry point. In the same way we can register multiple libraries or services. These services or libraries will be available in all modules., (*2)

Installation

With Composer

First we have to add the dependencies to the composer.json file:, (*3)

"require": {
    "othercode/fcontroller": "*",
}

Then we have to run the following command:, (*4)

composer update

Stand Alone

We need to download the package, then extract the content and include in your code the fcontroller/autoload.php file., (*5)

require_once 'fcontroller/autoload.php';

Basic Usage

First of all we must have the modules we want to the FController handle. For example we have this two dummy modules (classes):, (*6)

namespace OtherCode\Examples;

class DummyOne extends \OtherCode\FController\Modules\BaseModule
{
    public function sayHello($name)
    {
        $this->storage->name = $name;

        return "Hello, " . $name . "!";
    }
}

The DummyOne Module has one method sayHello($name) that accepts one string as parameter. This method return us a string., (*7)

namespace OtherCode\Examples;

class DummyTwo extends \OtherCode\FController\Modules\BaseModule
{
    public function sayGoodBye()
    {
        return "GoodBye, " . $this->storage->name . "!";
    }
}

The DummyTwo Module has once again only one method named sayGoodBye(), this method also, return us a string., (*8)

Lets create a simply application that holds our two modules:, (*9)

namespace OtherCode\Examples;

require_once 'fcontroller/autoload.php';
require_once 'DummyOne.php';
require_once 'DummyTwo.php';

$app = \OtherCode\FController\FController::getInstance();
$app->setModule('dummy1', 'OtherCode\Examples\DummyOne');
$app->setModule('dummy2', 'OtherCode\Examples\DummyTwo');

try {

    $response1 = $app->run("dummy1.sayHello", array('name' => 'Rick'));
    $response2 = $app->run("dummy2.sayGoodBye");

    var_dump($response1, $response2);

} catch (\Exception $e) {

    var_dump($e);
}

The code above illustrate how we can call two different modules using one entry point. Also we can use services inside our modules., (*10)

This package also has a message queue that can be used to display informative messages from our modules., (*11)

The Versions

07/10 2017

dev-develop

dev-develop

FController is a container for controllers/modules.

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Unay Santisteban

12/05 2017

dev-master

9999999-dev

FController is a container for controllers/modules.

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by David Unay Santisteban

28/08 2016

v1.2.0

1.2.0.0

FController is a container for controllers/modules.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by David Unay Santisteban

02/08 2016

v1.1.0

1.1.0.0

Front controller that allow you to run different API modules.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by David Unay Santisteban

23/04 2016

v1.0

1.0.0.0

Front controller that allow you to run different API modules.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by David Unay Santisteban