Gectrl PHP Generic Controller Class: Controller class that delegates in action classes

Recommend this page to a friend!
  Info   View files Documentation   View files View files (22)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2021-01-14 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 89 This week: 6All time: 9,571 This week: 50Up
Version License PHP version Categories
gectrl 1.0GNU Lesser Genera...7Design Patterns, PHP 7
Description Author

This package implements a controller class that delegates the request handling in action classes.

It can register multiple classes that implement the actions for each of the supported request type by the controller.

The controller can handle the requests and forward it the respective action class that was previously registered.

Innovation Award
PHP Programming Innovation award nominee
January 2021
Number 6
Model-View-Controller (MVC) based applications allow developers to structure their applications in separate classes that have different roles.

This possibility makes it easier to develop and maintain PHP applications.

The package allows to simplify further the implementation of MVC based applications by providing a generic controller class that can call separate classes to implement each type of action that the controller class is configured to handle.

Manuel Lemos
Picture of Kjell-Inge Gustafsson
  Performance   Level  
Name: Kjell-Inge Gustafsson <contact>
Classes: 14 packages by
Country: Sweden Sweden
Innovation award
Innovation award
Nominee: 5x

Details

[comment]: # (This file is part of Gectrl, PHP Genereric controller. Copyright 2021 Kjell-Inge Gustafsson, kigkonsult, All rights reserved, licence LGPLv3)

Gectrl

About

Gectrl is a PHP generic controller class package

  • Supports the MVC software design pattern
  • Distinguish controller and application logic using a strategy pattern

The controller provides coordination logic

The controller delegates application logic to actionClasses

  • using implementations of the (strategy) [ActionClassInterface],
  • invoking of actionClass condition evaluate and opt, logic doAction methods,
  • passing all data information in an encapsulated [Package] class instance * input, output, config, logger etc

Usage

Basic

Simpler (http/html) example

<?php
namespace Kigkonsult\Gectrl;
use ActionSrc\PrepAction;
use ActionSrc\CreateAction;
use ActionSrc\ReadAction;
use ActionSrc\UpdateAction;
use ActionSrc\DeleteAction;
use ActionSrc\CatchUpAction;
require 'vendor/autoload.php';

...

$package = Gectrl::init( $config, $logger )
    ->setActionClasses(
        [
            PrepAction::class,
            CreateAction::class,
            ReadAction::class,
            UpdateAction::class,
            DeleteAction::class,
            CatchUpAction::class,
        ]
    )
    ->main( $_REQUEST );
...

echo $package->getOutput();

For more detailed usage, read [Gectrl], [ActionClassInterface] and [Package] docs.

Installation

[Composer], from the Command Line:

composer require kigkonsult/gectrl

In your composer.json:

{
    "require": {
        "kigkonsult/gectrl": "dev-master"
    }
}

Sponsorship

Donation using [paypal.me/kigkonsult] are appreciated. For invoice, [e-mail]</a>.

Licence

Gectrl is licensed under the LGPLv3 License.

[ActionClassInterface]:docs/ActionClassInterface.md [Composer]:https://getcomposer.org/ [e-mail]:mailto:ical@kigkonsult.se [Gectrl]:docs/Gectrl.md [paypal.me/kigkonsult]:https://paypal.me/kigkonsult [Package]:docs/Package.md

  Files folder image Files  
File Role Description
Files folder image.github (1 file)
Files folder imagedocs (3 files)
Files folder imagesrc (3 files)
Files folder imagetest (2 files, 1 directory)
Accessible without login Plain text file autoload.php Aux. Auxiliary script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENCE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  .github  
File Role Description
  Accessible without login Plain text file FUNDING.yml Data Auxiliary data

  Files folder image Files  /  docs  
File Role Description
  Accessible without login Plain text file ActionClassInterface.md Data Auxiliary data
  Accessible without login Plain text file Gectrl.md Data Auxiliary data
  Accessible without login Plain text file Package.md Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file ActionClassInterface.php Class Class source
  Plain text file Gectrl.php Class Class source
  Plain text file Package.php Class Class source

  Files folder image Files  /  test  
File Role Description
Files folder imageAcSrc (8 files)
  Plain text file GectrlTest.php Class Class source
  Plain text file PackageTest.php Class Class source

  Files folder image Files  /  test  /  AcSrc  
File Role Description
  Plain text file Action0Base.php Class Class source
  Plain text file Action1Test.php Class Class source
  Plain text file Action3Test.php Class Class source
  Plain text file Action4Test.php Class Class source
  Plain text file ActionExampleTest.php Class Class source
  Plain text file OtherInterface.php Class Class source
  Plain text file OtherTest.php Class Class source
  Plain text file OtherTrait.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:89
This week:6
All time:9,571
This week:50Up

For more information send a message to info at phpclasses dot org.