PHPackages                             slabphp/controllers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. slabphp/controllers

ActiveLibrary[Framework](/categories/framework)

slabphp/controllers
===================

SlabPHP Controller Library

v0.1.11(8y ago)0822Apache-2.0PHP

Since Mar 12Pushed 7y ago1 watchersCompare

[ Source](https://github.com/SlabPHP/controllers)[ Packagist](https://packagist.org/packages/slabphp/controllers)[ Docs](https://www.salernolabs.com/slab)[ RSS](/packages/slabphp-controllers/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (5)Versions (13)Used By (2)

SlabPHP Controllers
===================

[](#slabphp-controllers)

This library houses the three main base SlabPHP Controllers employed by SlabPHP applications.

Yes, we know you may disagree with the abuse of protected methods in this architecture. Please see the main SlabPHP documentation for more information about SlabPHP, architecture concerns, or anything else.

Installation
------------

[](#installation)

Include this library

```
composer require slabphp/controllers

```

General Architecture of a Controller
------------------------------------

[](#general-architecture-of-a-controller)

Generally speaking a controller from this library will have three call sequences. The first is the input sequence, the second is the operations sequence, and the third is outputs. Functions get queued up in the appropriate sequences and then they all get called sequentially at once. This allows child classes to add more methods to the sequences. To accomplish this, you'll see a lot of protected methods. If this offends you, we apologize but SlabPHP is not for you.

### Inputs

[](#inputs)

The input sequence is generally used for determing the values that will be used in the operations phase.

### Operations

[](#operations)

This is usually where you will query for data based on inputs you determined in the input phase.

### Outputs

[](#outputs)

This is usually where you process data you queried in the operations phase into fields you can add to the $this-&gt;data member.

### Response

[](#response)

The response of a controller should be a class that adopts the \\Slab\\Components\\Output\\ControllerResponseInterface interface. The SlabPHP framework will then deal with it based on the logic of the display resolver that the controller prescribes.

Usage
-----

[](#usage)

Generally you should extend your controller class from \\Slab\\Controllers\\Page for a web page, \\Slab\\Controllers\\Feed for a JSON or XML feed, and \\Slab\\Controllers\\POSTBack for a controller you will POST data to and then redirect to another one.

### \\Slab\\Controllers\\Page

[](#slabcontrollerspage)

Extend your controller from here if you are making an HTML webpage or anything that will use the SlabPHP template display renderer.

For example,

```
