PHPackages                             katmore/flat - 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. [Templating &amp; Views](/categories/templating)
4. /
5. katmore/flat

ActiveLibrary[Templating &amp; Views](/categories/templating)

katmore/flat
============

experimental framework for php

v1.5.5(6y ago)042321MITPHPPHP &gt;=7.2.1

Since Nov 10Pushed 6y ago2 watchersCompare

[ Source](https://github.com/katmore/flat)[ Packagist](https://packagist.org/packages/katmore/flat)[ Docs](https://github.com/katmore/flat)[ RSS](/packages/katmore-flat/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (4)Versions (56)Used By (1)

The Flat Framework
==================

[](#the-flat-framework)

**An experimental framework for php**

It was created to allow a project to be organized in a hierarchical manner similar to a REST service.

Architecturally, it facilitates a broad swathe of design patterns using a client-server process flow.

Features
--------

[](#features)

- HTML templating: convenience classes facilitating sophisticated templating
- Front-End Routing: flexible dynamic routing for the HTML views
- Back-End Webservice: convienence classes to faciliate actual RESTful APIs
- Command line scripts: convenience classes to faciliate creation of recurring (cron), deamons, and ad-hoc scripts

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

[](#installation)

**The Flat Framework** can be the basis of a **new project** or added to an **existing project**

### New Projects

[](#new-projects)

The easiest way to get going with **The Flat Framework** is to copy the [flat boilerplate webapp](https://github.com/katmore/flat-webapp).

**Step 1. Composer 'create-project'** (*flat boilerplate webapp*)...

```
composer create-project katmore/flat-webapp my_project_dir
```

*(copies this repo and configures php dependencies)*

**Step 2. Bower update**

```
cd my_project_dir
bower update
```

*(installs static dependencies)*

### Existing Projects

[](#existing-projects)

**Step 1. Using composer**

```
cd my_project_dir
composer require katmore/flat
```

**Step 2. Bower update**

```
cd my_project_dir
bower update
```

Architecture
------------

[](#architecture)

The components of *flat* architecture facilitate a *client-server* process flow...

- **resources**: An abstract hierarchical tree of the applications components.
- **app objects**: A group of instantiable php objects.
- **app routes**: A group of of *routes* that an application controller can access to resolve a *client* request.
- **app controllers**: A group of application "entry-points"; i.e. the "server" which processes a *request* from the "client".
- **requests**: A *request* consists of a client inquiry which provides a *resource* and any associated input data to an *app controller*.
- **route maps**: A *route map* consists of multiple routes that each must be *resolved* by an *app controller*
- **resolvers**: A *resolver* instantiates *app objects* when given a *resource*.

Admittedly, the component organization of the *flat* architecture is rigidly attached to the *client-server* model. Despite this, the programming design constraints of a *flat* based project are actually very minimal. For this reason, *flat* can be argued to be a *lightweight framework*. Any programming design pattern can be used within a *flat* project.

However... there is an idealized programming design use case neatly bundled within the architecture.

Groan...yes, it is yet another design pattern.

The **Resource-Route-Controller** is a novel design pattern invented in tandem with *flat*. It is, though, intended to be a very lightweight design pattern that should not keep other design patterns (MVC, MVP, MVVM) from being incorporated. It is described further in a section below.

The hierarchical organization of a *flat* project is abstracted into multiple abstract levels of programming design (not just the path names of scripts and dependency file structure).

The following sections contain further details regarding concepts and terminology encountered in *flat*.

### Resource:

[](#resource)

A "resource" is a string value comprised of one or more "segments", each "segment" being delineated by either a backslash "" or forward-slash "/".

For example, given the following URL:

```
https:/example.com/my_app/my_app_frontend/my_frontend_view

```

An *app controller* might extract the URL path as the *resource* `/my_app/my_app_frontend/my_frontend_view`and then check if a php class exists with the name `\my_app\my_app_frontend\my_frontend_view`, and instantiate the class, which becomes an *app object*...

```
$check_class = $_SERVER ['PATH_INFO'];
$check_class = str_replace('/','\\',$check_class);
if (class_exists($check_class)) {
   new $check_class;
}
```

*Note:**flat* has convenience classes that facilitate more complex routing than the trivial example above. These facilitate more complex aspects, such as dealing with associated request input data.

*See*\* **Route Rules** definition below \* **Route Factory** definition below \* **Resolver Class**

### Route Factory:

[](#route-factory)

A "route factory" facilitates creating a "route map" for resolving a "resource".

### Route Map:

[](#route-map)

A "route map" consists of "route rules" which determine how a "resource" corresponds to php classnames within a php sub-namespace.

### Entry Point Controller:

[](#entry-point-controller)

An entry-point controller script uses a "resolver" to instantiate "app objects". based on the "route map" logic created in this

An example of an entry-point script can be seen in the 'flat-webapp' github repo:

The "Resource-Route-Controller" Design Pattern
----------------------------------------------

[](#the-resource-route-controller-design-pattern)

- **resource**
- **input** data associated
- **controller**
- **request** Determines the *resource* (and any *input*) to provide the *controller*

"Resource-Route-Controller"
---------------------------

[](#resource-route-controller)

Ideal process flow incorporating *Resource-Route-Controller* design using 'client-server' model

1. An application controller is provided a "resource" along with any "input"
2. A controller "resolves" the "resource" into one or more objects which contain the application logic.

Legal
-----

[](#legal)

Copyright (c) 2012-2019 Doug Bird - . All Rights Reserved.

This software is distributed under the terms of the [MIT license](LICENSE) or the [GNU General Public License v3.0](GPLv3).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 98.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~22 days

Recently: every ~30 days

Total

55

Last Release

2258d ago

PHP version history (3 changes)v1.0.0-alphaPHP &gt;=7.0.1

1.0.4PHP &gt;=7.1.1

v1.3.1PHP &gt;=7.2.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef3cde32b1ac961c229cb3e76202b38b5d1a2c571334152c6cee08c43732ce7c?d=identicon)[acksponies](/maintainers/acksponies)

---

Top Contributors

[![ackspony](https://avatars.githubusercontent.com/u/1947018?v=4)](https://github.com/ackspony "ackspony (119 commits)")[![sunnyw1212](https://avatars.githubusercontent.com/u/13045303?v=4)](https://github.com/sunnyw1212 "sunnyw1212 (2 commits)")

---

Tags

flat-frameworkhttp-routerhttp-routingphp-frameworkphp-libraryphp7rest-apirestfulrestful-apirestful-webservicestemplate-enginetemplatingvanilla-phpwebservice

### Embed Badge

![Health badge](/badges/katmore-flat/health.svg)

```
[![Health](https://phpackages.com/badges/katmore-flat/health.svg)](https://phpackages.com/packages/katmore-flat)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[nystudio107/craft-twigpack

Twigpack is a bridge between Twig and webpack, with manifest.json &amp; webpack-dev-server HMR support

97341.4k17](/packages/nystudio107-craft-twigpack)[mallardduck/blade-boxicons

A package to easily make use of Boxicons in your Laravel Blade views.

12776.5k9](/packages/mallardduck-blade-boxicons)[localgovdrupal/localgov_base

The base theme for LocalGov Drupal websites.

13121.5k4](/packages/localgovdrupal-localgov-base)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
