shahburhan/owa
Composer 安装命令:
composer require shahburhan/owa
包简介
Laravel Package for object oriented design with actions
README 文档
README
Object oriented structural design for creating objects coupled together with actions
Highlights
- This package considers every Model as an Object and creates the Objects and Actions based on that concept.
- This package introduces the concept of Object Actions which promotes segregation of any Object (\App\Object{object}) related business logic into dedicated Action (\App\Objects{object}\Actions{action}) classes.
- An action can use argument count as a means to differentiate between action types or sub actions.
- Every Action extends an abstract class (Action) and is required to implement a public take method on it.
How to use Actions
- There are two ways to initiate/use an action
- An action can be called directly by instantiating an Action class and calling it's take method
$action = new ActionName;
$response = $action->take($args);
- Or using the base class, an action can be initiated by following the syntax
$response = Action::ObjectNameActionName($args);
This is can be percived both as syntactical sugar and a reductor in your number of lines of code as it saves you from importing all the Action classes. You only import the base Action class.
Namespace
All your Objects by default go in \App\Objects and Actions go in the Actions directory of a particular object. The same can be configured in the owa config file
- app
- Objects
- ExampleObject
- Actions
- ExampleAction.php
- Actions
- ExampleObject
- Objects
Nomenclature/Conventions
For the purpose of consistency a specific naming convention is followed primarily with routing(optional) and action names.
-
Every action is named in the format name of the action followed by the suffix Action.
- Example: For a search action, the action class will be named SearchAction.php.
-
The route defination convention is optional but can be followed in accordance with an object and route specific action, following the course base_url/object/action.
- Example: If we are searching for a store, we will probably have an action in the Store object named SearchAction. The route for the same according to above convention will be base_url/store/search
-
If a route is an active record route or a SingularAction*, it can be followed by the same object/action convention for active record specific sub actions
- Example if we have a store and we want to search an item within that store and we have a SearchAction in Item Object, the route will be defined as base_url/store/{store_reference}/item/search
-
The route conventions are for the sake of easily discovering the source files and is totally optional.
[*] SingularActions are those actions where there is an identifier passed in the url instead of an action name. Eg. For a specific store we might have an endpoint like base_url/store/{store_reference}
shahburhan/owa 适用场景与选型建议
shahburhan/owa 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 02 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 shahburhan/owa 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shahburhan/owa 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-07