agorlov/lipid 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

agorlov/lipid

Composer 安装命令:

composer require agorlov/lipid

包简介

Object approach framework for web apps

README 文档

README

Hits-of-Code Maintainability codecov

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

  1. 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
  1. Micro-format, like lipid is.

  2. From Lipid framework to Lipid as process (including design principles, rules, ci/cd)

Library development cycle

  1. Clone repository

  2. $ composer install

  3. $ composer dump-autoload

  4. $ composer example

  5. open browser: http://localhost:8000/

  6. look at the source code: example/ directory.

  7. Put some changes, create branch for issue:

$ git checkout -b 'Issue123'
  1. Check and fix PSR2 $ composer phpcs and $composer phpcs-fix

  2. Check by unit tests:

$ composer tests
  1. 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:

  1. run phpmd: $ composer phpmd-xml
  2. look at rule name
  3. 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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 9.33k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 4
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-13