{"id":15029168,"url":"https://github.com/katmore/flat","last_synced_at":"2026-04-02T01:26:38.606Z","repository":{"id":23784277,"uuid":"27159713","full_name":"katmore/flat","owner":"katmore","description":"an experimental framework for php","archived":false,"fork":false,"pushed_at":"2020-03-09T14:02:44.000Z","size":800,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-01-02T07:22:06.016Z","etag":null,"topics":["flat-framework","http-router","http-routing","php-framework","php-library","php7","rest-api","restful","restful-api","restful-webservices","template-engine","templating","vanilla-php","webservice"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/katmore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-26T04:35:05.000Z","updated_at":"2020-03-09T14:02:02.000Z","dependencies_parsed_at":"2022-08-05T23:15:13.206Z","dependency_job_id":null,"html_url":"https://github.com/katmore/flat","commit_stats":null,"previous_names":[],"tags_count":55,"template":false,"template_full_name":null,"purl":"pkg:github/katmore/flat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katmore%2Fflat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katmore%2Fflat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katmore%2Fflat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katmore%2Fflat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/katmore","download_url":"https://codeload.github.com/katmore/flat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/katmore%2Fflat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31293841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:05:07.454Z","status":"ssl_error","status_checked_at":"2026-04-02T00:56:46.496Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flat-framework","http-router","http-routing","php-framework","php-library","php7","rest-api","restful","restful-api","restful-webservices","template-engine","templating","vanilla-php","webservice"],"created_at":"2024-09-24T20:09:52.138Z","updated_at":"2026-04-02T01:26:38.560Z","avatar_url":"https://github.com/katmore.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Flat Framework\n\n**An experimental framework for php**\n\nIt was created to allow a project to be organized in a hierarchical manner similar to a REST service.\n\nArchitecturally, it facilitates a broad swathe of design patterns using a client-server process flow.\n\n## Features\n * HTML templating: convenience classes facilitating sophisticated templating\n * Front-End Routing: flexible dynamic routing for the HTML views\n * Back-End Webservice: convienence classes to faciliate actual RESTful APIs\n * Command line scripts: convenience classes to faciliate creation of recurring (cron), deamons, and ad-hoc scripts\n\n## Installation\n**The Flat Framework** can be the basis of a **new project** or added to an **existing project**\n\n### New Projects\nThe easiest way to get going with **The Flat Framework** is to copy the [flat boilerplate webapp](https://github.com/katmore/flat-webapp).\n\n**Step 1. Composer 'create-project'** (*flat boilerplate webapp*)...\n\n```bash\ncomposer create-project katmore/flat-webapp my_project_dir\n```\n*(copies this repo and configures php dependencies)*\n\n**Step 2. Bower update**\n```bash\ncd my_project_dir\nbower update\n```\n*(installs static dependencies)*\n\n### Existing Projects\n**Step 1. Using composer**\n```bash\ncd my_project_dir\ncomposer require katmore/flat\n```\n\n**Step 2. Bower update**\n```bash\ncd my_project_dir\nbower update\n```\n\n## Architecture\nThe components of *flat* architecture facilitate a *client-server* process flow...\n\n  * **resources**: An abstract hierarchical tree of the applications components.\n  * **app objects**: A group of instantiable php objects.\n  * **app routes**: A group of of *routes* that an application controller can access to resolve a *client* request.\n  * **app controllers**: A group of application \"entry-points\"; i.e. the \"server\" which processes a *request* from the \"client\".\n  * **requests**: A *request* consists of a client inquiry which provides a *resource* and any associated input data to an *app controller*.\n  * **route maps**: A *route map* consists of multiple routes that each must be *resolved* by an *app controller*\n  * **resolvers**: A *resolver* instantiates *app objects* when given a *resource*.\n\nAdmittedly, 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.\n\nHowever... there is an idealized programming design use case neatly bundled within the architecture.\n\nGroan...yes, it is yet another design pattern.\n\nThe **Resource-Route-Controller** is a novel design pattern invented in tandem with *flat*.\nIt 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.\n\nThe 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).\n\nThe following sections contain further details regarding concepts and terminology encountered in *flat*.\n\n### Resource:\n   A \"resource\" is a string value comprised of one or more \"segments\", \n   each \"segment\" being delineated by either a backslash \"\\\" or forward-slash \"/\".\n   \n   For example, given the following URL:\n   \n```\nhttps:/example.com/my_app/my_app_frontend/my_frontend_view\n```\n\n   An *app controller* might extract the URL path as the *resource* `/my_app/my_app_frontend/my_frontend_view`\n   and then check if a php class exists with the name `\\my_app\\my_app_frontend\\my_frontend_view`, and instantiate\n   the class, which becomes an *app object*...\n   \n```php\n$check_class = $_SERVER ['PATH_INFO'];\n$check_class = str_replace('/','\\\\',$check_class);\nif (class_exists($check_class)) {\n   new $check_class;\n}\n```\n   \n   *Note:*\n   *flat* has convenience classes that facilitate more complex routing than the trivial example above.\n   These facilitate more complex aspects, such as dealing with associated request input data.\n   \n   *See*\n    * **Route Rules** definition below\n    * **Route Factory** definition below\n    * **Resolver Class** https://github.com/katmore/flat/blob/master/src/flat/core/resolver.php\n\n\n### Route Factory:\n   A \"route factory\" facilitates creating a \"route map\" for resolving a \"resource\".\n\n### Route Map:\n   A \"route map\" consists of \"route rules\" which determine how a \"resource\" \n   corresponds to php classnames within a php sub-namespace.\n   \n### Entry Point Controller:\n   An entry-point controller script uses a \"resolver\" to instantiate \"app objects\". based\n   on the \"route map\" logic created in this  \n   \n   An example of an entry-point script can be seen in the 'flat-webapp' github repo:\n      https://github.com/katmore/flat-webapp/blob/master/web/api.php\n\n## The \"Resource-Route-Controller\" Design Pattern\n  * **resource**\n   * **input** data associated\n  * **controller**\n   * **request** Determines the *resource* (and any *input*) to provide the *controller*\n  \n## \"Resource-Route-Controller\" \n  Ideal process flow incorporating *Resource-Route-Controller* design using 'client-server' model\n  1. An application controller is provided a \"resource\" along with any \"input\"\n  2. A controller \"resolves\" the \"resource\" into one or more objects which \n     contain the application logic.\n\n## Legal\nCopyright (c) 2012-2019 Doug Bird - \u003cretran@gmail.com\u003e. All Rights Reserved.\n\nThis software is distributed under the terms of the [MIT license](LICENSE) or the [GNU General Public License v3.0](GPLv3).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatmore%2Fflat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatmore%2Fflat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatmore%2Fflat/lists"}