agorlov/lipid
Composer 安装命令:
composer require agorlov/lipid
包简介
Object approach framework for web apps
README 文档
README
Lipid is an objects designed microframework for PHP web apps.
Quickstart
Create app directory:
$ mkdir testapp $ composer require agorlov/lipid
Lipid is installed, start with example app, run:
$ vendor/bin/lipidstrap
3 files will be created:
index.php- it's your app, it consists of actions-objects for each page or request;src/ActIndex.php- it's example action for main page;tpl/index.twig- it's example index page template.
And start your app:
$ php -S localhost:8000 index.php
Finaly open browser: http://localhost:8000
Enjoy Result and start creating your app pages.
How to create Actions (pages or api-responses)
ActIndex.php
<?php class ActIndex implements Action { public function handle(Response $resp): Response { return $resp->withBody( "Hello, World 2!<br>" . '<a href="/login">login</a>' ); } }
If we need database or GET params, put it in constructor:
In this example $_GET['test'] -> with $this->GET array
<?php class ActIndex implements Action { private $rqGet; public function __construct(array $GET = null) { $this->rqGet = $GET ?? $_GET; } public function handle(Response $resp): Response { $test = $this->GET['test'] ?? 'nothing'; return $resp->withBody( "Hello, World 2!<br>" . '<a href="/login">login</a>' . '$_GET[test]=' . htmlentities($test) ); } }
GET request, POST request, Database, Config, Environment, Session:
<?php public function __construct( array $GET = null, AppPDO $db = null, Config $config = null, Request $env = null, Session $sess = null, Tpl $tpl // or anything you need for your Action ) { $this->POST = $GET ?? $_POST; $this->GET = $GET ?? $_GET; $this->db = $db ?? new AppPDO; $this->config = $config ?? new CfgFile; $this->env = $env ?? new RqENV; $this->tpl = $tpl ?? new AppTpl }
Design principles
- True OOP:
- each object is representation of domain term
- no static,
- small objects,
- without extends,
- wide use of decorators,
- strict CI/CD piplene: unit tests, PSR2 checker,
- immutable
- inspired by @yegor256 Elegant Objects
-
Micro-format, like lipid is.
-
From
Lipid frameworkto Lipid as process (including design principles, rules, ci/cd)
Library development cycle
-
Clone repository
-
$ composer install -
$ composer dump-autoload -
$ composer example -
open browser: http://localhost:8000/
-
look at the source code: example/ directory.
-
Put some changes, create branch for issue:
$ git checkout -b 'Issue123'
-
Check and fix PSR2
$ composer phpcsand$composer phpcs-fix -
Check by unit tests:
$ composer tests
- commit, push and create PR.
git commit -m 'Thats was done closes #123' -a
git push --set-upstream origin Issue123
PHPMD
@todo #75 setup and add phpmd to merge checks
To disable some nasty rule, add comment:
- run phpmd:
$ composer phpmd-xml - look at rule name
- add string
@SuppressWarnings("rule name")to phpdoc block of method or class
/**
* Class Title
*
* ..
* @SuppressWarnings("ElseExpression")
* ..
*/
agorlov/lipid 适用场景与选型建议
agorlov/lipid 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.33k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2019 年 09 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「php」 「library」 「web」 「OOP」 「Applications」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 agorlov/lipid 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 agorlov/lipid 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 agorlov/lipid 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Inbox pattern process implementation for your Laravel Applications
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Provides command to manage a web library directory
Alfabank REST API integration
统计信息
- 总下载量: 9.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-13