定制 katmore/flat 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

katmore/flat

Composer 安装命令:

composer require katmore/flat

包简介

experimental framework for php

README 文档

README

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

  • 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

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

New Projects

The easiest way to get going with The Flat Framework is to copy the flat boilerplate 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

Step 1. Using composer

cd my_project_dir
composer require katmore/flat

Step 2. Bower update

cd my_project_dir
bower update

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:

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 https://github.com/katmore/flat/blob/master/src/flat/core/resolver.php

Route Factory:

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

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:

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: https://github.com/katmore/flat-webapp/blob/master/web/api.php

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"

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

Copyright (c) 2012-2019 Doug Bird - retran@gmail.com. All Rights Reserved.

This software is distributed under the terms of the MIT license or the GNU General Public License v3.0.

katmore/flat 适用场景与选型建议

katmore/flat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 423 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 03 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 katmore/flat 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 katmore/flat 我们能提供哪些服务?
定制开发 / 二次开发

基于 katmore/flat 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 423
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-03