slabphp/controllers
Composer 安装命令:
composer require slabphp/controllers
包简介
SlabPHP Controller Library
关键字:
README 文档
README
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
Include this library
composer require slabphp/controllers
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
The input sequence is generally used for determing the values that will be used in the operations phase.
Operations
This is usually where you will query for data based on inputs you determined in the input phase.
Outputs
This is usually where you process data you queried in the operations phase into fields you can add to the $this->data member.
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
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
Extend your controller from here if you are making an HTML webpage or anything that will use the SlabPHP template display renderer.
For example,
<?php
namespace My\Site\Controllers\Homepage;
class Homepage extends \Slab\Controllers\Page
{
protected $title = "Homepage!";
protected $description = "Page Description!";
}
By creating this class SlabPHP will automatically attempt to render the template ~\src\views\shell.php with ~\src\views\pages\homepage.php as the subTemplateName for the content area.
The Page controller accepts the following parameters from routes.
- pageTitle - specifies the page's title
- pageDescription - specifies the page's description
- contentType - specifies the content-type header, defaults to text/html;charset=utf-8
- displayResolver - specifies the slabphp display resolver class to use, defaults to \Slab\Display\Resolvers\Template
- template - specifies the main shell template to use
- subTemplate - specifies the sub template file to insert into the shell
It is possible to create pages completely from the routing parameters using the Page class as your controller.
\Slab\Controllers\Feed
Extend your controller from here if you are making an XML or JSON feed. This controller will read the feedType parameter and if it's "json" or "xml" it will encode the output properly.
JSON feeds will also respond to the ?callback= query parameter and format the output as JSONP.
\Slab\Controllers\POSTBack
Extend your controller from here if you are making an controller that gets data posted to it and needs to redirect back to another controller afterwards. Do your logic and set $this->redirectRoute and $this->redirectParameters to automatically query the router for the correct URL and redirect to it.
The POSTBack controller will manage session flash data for you based on the constants in the class.
Whatever
SlabPHP mostly operates based on interfaces. Adopt the interfaces and make your own controllers if you want, we're not the police.
slabphp/controllers 适用场景与选型建议
slabphp/controllers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 83 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 03 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「controllers」 「slab」 「slabphp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 slabphp/controllers 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 slabphp/controllers 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 slabphp/controllers 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Opinionated Laravel Controllers extension
A package for generating annotations and drawing SwUi when working with Bitrix controllers.
Bullet development for Laravel Applications
Bundle of annotations to make it easier and faster to develop Rest APIs with Symfony.
Div PHP Ways
Alfabank REST API integration
统计信息
- 总下载量: 83
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2018-03-14