设为首页收藏本站

LUPA开源社区

 找回密码
 注册
文章 帖子 博客
LUPA开源社区 首页 业界资讯 软件追踪 查看内容

QueryPHP v1-rc.3发布,更新到PHP-7.4

2020-1-3 09:37| 发布者: joejoe0332| 查看: 140| 评论: 0|原作者: oschina|来自: oschina

摘要: QueryPHP v1.0.0-rc.3 主要用 PHP-7.4 新特性对整个框架进行改造,例外增加多个组件的文档,除此之外对 ORM 实体 Entity 进行了优化。 QueryPHP 1.0.0 正式版快完成了,现在主要是推进文档的编写,少量的优化。 关于 ...

QueryPHP v1.0.0-rc.3 主要用 PHP-7.4 新特性对整个框架进行改造,例外增加多个组件的文档,除此之外对 ORM 实体 Entity 进行了优化。

QueryPHP 1.0.0 正式版快完成了,现在主要是推进文档的编写,少量的优化。

关于 QueryPHP

QueryPHP 是一款现代化的高性能 PHP 渐进式协程框架, 我们还是主要面向传统 PHP-FPM 场景,以工程师用户体验为历史使命,让每一个 PHP 应用都有一个好框架。

百分之百单元测试覆盖直面 Bug,致力于创造高品质的产品 level level leevel,依托 Swoole 协程提升业务性能,此刻未来逐步渐进。 我们的愿景是USE LEEVEL WITH SWOOLE DO BETTER, 让您的业务撑起更多的用户服务。

更新日志

  • 【framework】使用 PHP 7.4 的新语法重构代码,主要是整个框架和应用的类属性类型支持。
  • 【framework】强化了 php leevel make:entity 功能,能实现局部自动更新表结构,支持两种 getter setter。
  • 【framework】修复了实体 Entity 在模拟 replace 场景中不存在主键自动忽略并返回重构
  • 【framework】改进多语言文档生成的 `uses` 样式以及删除 Doc::getClassBody多余的 `uses`
  • 【framework】tableColumns 返回更多字段信息,以及加入表的注释,目前用于生成实体的文件名字
  • 【framework】composer 加入一个常用 scripts,比如 composer migrate,composer test
  • 【framework】配置 php_cs no_superfluous_phpdoc_tags 清理掉系统无用的注释,删除掉文件头部的 author version since 等注释
  • 【framework】分页第一页从 1 开始,小于 1 将抛出异常统一规范
  • 【framework】简化所有验证器规则 Leevel\Validate\Helper\validate_accepted 为 Leevel\Validate\Helper\accepted
  • 【framework】修复部分助手函数的 bug,并精简 api 命名,Leevel\Session\Helper|session_set 改为 Leevel\Session\Helper|set
  • 【framework】增加部分 HTTP 组件文档
  • 【framework】增加小部分 Swoole 文档
  • 【framework】新增 Option 配文档
  • 【framework】新增 Cache 缓文档
  • 【framework】新增 Session 文档
  • 【framework】新增 Page 分页文档
  • 【framework】新增 Log 日志文档
  • 【framework】新增 Seccode 验证码文档
  • 【application】php 7.4 类型属性支持
  • 【application】精简所有注释,删除所有 author version 等信息
  • 【application】重新更新到全新的实体 entity
  • 【application】composer 加入一个常用 scripts,比如 composer migrate,composer test

RoadMap

  • 【framework】rc.1-6 是整个框架发布 GA 版最后几个版本。
  • 【framework】RC 版本只修复 BUG、单元测试 和文档完善,不排除可能有一些必要的功能微调。
  • 【framework】QueryPHP v1.0.0 正式版本计划是在 2019.12 或者 2020.01 发布。

安装

composer create-project hunzhiwange/queryphp myapp dev-master
php leevel server <Visite http://127.0.0.1:9527/>

 

运行基于 IViewUI 的通用权限系统

cd /data/codes/queryphp/frontend
npm install
npm run dev

cd /data/codes/queryphp
php leevel server

http://127.0.0.1:9528/#/login

PHP 7.4

类属性类型支持

早在 PHP-7.4 alpha.1 开始就拉了一个分支编写 PHP-7.4,所以在这个版本已经全部重构完毕并合并。

https://github.com/hunzhiwange/framework/blob/master/src/Leevel/Router/Router.php

<?php

declare(strict_types=1);

namespace Leevel\Router;
use Leevel\Di\IContainer;
use Leevel\Http\IRequest;
use Leevel\Http\IResponse;
use Leevel\Http\Response;
use Leevel\Pipeline\Pipeline;

/**
 * 路由解析.
 */
class Router implements IRouter
{
    /**
     * IOC Container.
     *
     * @var \Leevel\Di\IContainer
     */
    protected IContainer $container;

    /**
     * HTTP 请求
     *
     * @var \Leevel\Http\IRequest
     */
    protected IRequest $request;

    /**
     * 路由匹配数据.
     *
     * @var null|array
     */
    protected ?array $matchedData = null;

    ...
}

短闭包

https://github.com/hunzhiwange/framework/blob/master/src/Leevel/Router/Provider/Register.php

除了短闭包,还有不少协变逆变的应用。

<?php

declare(strict_types=1);

namespace Leevel\Router\Provider;

...

/**
 * router 服务提供者.
 */
class Register extends Provider
{
    /**
     * 注册 router 服务.
     */
    protected function router(): void
    {
        $this->container
            ->singleton(
                'router',
                fn (IContainer $container): Router => new Router($container),
            );
    }

 

强化的实体生成

系统支持两种实体展示,功能一致,可以满足不同的方式,支持局部更新 `--refresh` 和 强制更新 `--force`。

支持软删除 const DELETE_AT 和 show_prop_black 隐私属性的支持。

php leevel make:entity user --subdir=user

https://github.com/hunzhiwange/queryphp/blob/master/common/Domain/Entity/User/User.php

<?php

declare(strict_types=1);

/*
 * This file is part of the your app package.
 *
 * The PHP Application For Code Poem For You.
 * (c) 2018-2099 http://yourdomian.com All rights reserved.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Common\Domain\Entity\User;

use Leevel\Database\Ddd\Entity;
use Leevel\Database\Ddd\Relation\ManyMany;

/**
 * 用户.
 */
class User extends Entity
{
    /**
     * Database table.
     *
     * @var string
     */
    const TABLE = 'user';

    /**
     * Primary key.
     *
     * @var string
     */
    const ID = 'id';

    /**
     * Auto increment.
     *
     * @var string
     */
    const AUTO = 'id';

    /**
     * Entity struct.
     *
     * - id
     *                   comment: ID  type: int(11) unsigned  null: false
     *                   key: PRI  default: null  extra: auto_increment
     * - name
     *                   comment: 用户名字  type: varchar(64)  null: false
     *                   key:   default:   extra:
     * - num
     *                   comment: 编号  type: varchar(64)  null: false
     *                   key: MUL  default:   extra:
     * - password
     *                   comment: 密码  type: varchar(255)  null: false
     *                   key:   default:   extra:
     * - email
     *                   comment: Email  type: varchar(100)  null: false
     *                   key:   default:   extra:
     * - mobile
     *                   comment: 手机  type: char(11)  null: false
     *                   key:   default:   extra:
     * - status
     *                   comment: 状态 0=禁用;1=启用;  type: tinyint(4)  null: false
     *                   key:   default: 1  extra:
     * - create_at
     *                   comment: 创建时间  type: datetime  null: false
     *                   key:   default: CURRENT_TIMESTAMP  extra:
     * - update_at
     *                   comment: 更新时间  type: datetime  null: false
     *                   key:   default: CURRENT_TIMESTAMP  extra: on update CURRENT_TIMESTAMP
     * - delete_at
     *                   comment: 删除时间 0=未删除;大于0=删除时间;  type: bigint(20) unsigned  null: false
     *                   key:   default: 0  extra:
     * - create_account
     *                   comment: 创建账号  type: int(11) unsigned  null: false
     *                   key:   default: 0  extra:
     * - update_account
     *                   comment: 更新账号  type: int(11) unsigned  null: false
     *                   key:   default: 0  extra:
     *
     * @var array
     */
    const STRUCT = [
        'id' => [
            self::READONLY => true,
        ],
        'name' => [
        ],
        'num' => [
        ],
        'password' => [
            self::SHOW_PROP_BLACK => true,
        ],
        'email' => [
        ],
        'mobile' => [
        ],
        'status' => [
        ],
        'create_at' => [
        ],
        'update_at' => [
            self::SHOW_PROP_BLACK => true,
        ],
        'delete_at' => [
            self::SHOW_PROP_BLACK => true,
        ],
        'create_account' => [
            self::SHOW_PROP_BLACK => true,
        ],
        'update_account' => [
            self::SHOW_PROP_BLACK => true,
        ],
        'role'      => [
            self::MANY_MANY              => Role::class,
            self::MIDDLE_ENTITY          => UserRole::class,
            self::SOURCE_KEY             => 'id',
            self::TARGET_KEY             => 'id',
            self::MIDDLE_SOURCE_KEY      => 'user_id',
            self::MIDDLE_TARGET_KEY      => 'role_id',
            self::RELATION_SCOPE         => 'role',
        ],
    ];

    /**
     * Soft delete column.
     *
     * @var string
     */
    const DELETE_AT = 'delete_at';

    /**
     * 状态值.
     *
     * @var array
     */
    const STATUS_ENUM = [
        'disable' => [0, '禁用'],
        'enable'  => [1, '启用'],
    ];

    /**
     * Prop data.
     *
     * @var array
     */
    private array $data = [];

    /**
     * Database connect.
     *
     * @var mixed
     */
    private static $connect;

    /**
     * Setter.
     *
     * @param mixed $value
     */
    public function setter(string $prop, $value): self
    {
        $this->data[$this->realProp($prop)] = $value;

        return $this;
    }

    /**
     * Getter.
     *
     * @return mixed
     */
    public function getter(string $prop)
    {
        return $this->data[$this->realProp($prop)] ?? null;
    }

    /**
     * Set database connect.
     *
     * @param mixed $connect
     */
    public static function withConnect($connect): void
    {
        static::$connect = $connect;
    }

    /**
     * Get database connect.
     */
    public static function connect()
    {
        return static::$connect;
    }

    /**
     * 角色关联查询作用域.
     */
    protected function relationScopeRole(ManyMany $relation): void
    {
        $relation->setColumns(['id', 'name']);
    }
}

php leevel make:entity user --subdir=user --prop

<?php

declare(strict_types=1);

/*
 * This file is part of the your app package.
 *
 * The PHP Application For Code Poem For You.
 * (c) 2018-2099 http://yourdomian.com All rights reserved.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Common\Domain\Entity\User;

use Leevel\Database\Ddd\Entity;

/**
 * 用户.
 */
class User extends Entity
{
    /**
     * Database table.
     *
     * @var string
     */
    const TABLE = 'user';

    /**
     * Primary key.
     *
     * @var string
     */
    const ID = 'id';

    /**
     * Auto increment.
     *
     * @var string
     */
    const AUTO = 'id';

    /**
     * Entity struct.
     *
     * - id
     *                   comment: ID  type: int(11) unsigned  null: false  
     *                   key: PRI  default: null  extra: auto_increment
     * - name
     *                   comment: 用户名字  type: varchar(64)  null: false  
     *                   key:   default:   extra: 
     * - num
     *                   comment: 编号  type: varchar(64)  null: false  
     *                   key: MUL  default:   extra: 
     * - password
     *                   comment: 密码  type: varchar(255)  null: false  
     *                   key:   default:   extra: 
     * - email
     *                   comment: Email  type: varchar(100)  null: false  
     *                   key:   default:   extra: 
     * - mobile
     *                   comment: 手机  type: char(11)  null: false  
     *                   key:   default:   extra: 
     * - status
     *                   comment: 状态 0=禁用;1=启用;  type: tinyint(4)  null: false  
     *                   key:   default: 1  extra: 
     * - create_at
     *                   comment: 创建时间  type: datetime  null: false  
     *                   key:   default: CURRENT_TIMESTAMP  extra: 
     * - update_at
     *                   comment: 更新时间  type: datetime  null: false  
     *                   key:   default: CURRENT_TIMESTAMP  extra: on update CURRENT_TIMESTAMP
     * - delete_at
     *                   comment: 删除时间 0=未删除;大于0=删除时间;  type: bigint(20) unsigned  null: false  
     *                   key:   default: 0  extra: 
     * - create_account
     *                   comment: 创建账号  type: int(11) unsigned  null: false  
     *                   key:   default: 0  extra: 
     * - update_account
     *                   comment: 更新账号  type: int(11) unsigned  null: false  
     *                   key:   default: 0  extra: 
     * 
     * @var array
     */
    const STRUCT = [
        'id' => [
            self::READONLY => true,
        ],
        'name' => [
        ],
        'num' => [
        ],
        'password' => [
        ],
        'email' => [
        ],
        'mobile' => [
        ],
        'status' => [
        ],
        'create_at' => [
        ],
        'update_at' => [
            self::SHOW_PROP_BLACK => true,
        ],
        'delete_at' => [
            self::SHOW_PROP_BLACK => true,
        ],
        'create_account' => [
            self::SHOW_PROP_BLACK => true,
        ],
        'update_account' => [
            self::SHOW_PROP_BLACK => true,
        ],
    ];

    /**
     * Soft delete column.
     *
     * @var string
     */
    const DELETE_AT = 'delete_at';

    /**
     * ID.
     */
    private $_id;

    /**
     * 用户名字.
     */
    private $_name;

    /**
     * 编号.
     */
    private $_num;

    /**
     * 密码.
     */
    private $_password;

    /**
     * Email.
     */
    private $_email;

    /**
     * 手机.
     */
    private $_mobile;

    /**
     * 状态 0=禁用;1=启用;.
     */
    private $_status;

    /**
     * 创建时间.
     */
    private $_createAt;

    /**
     * 更新时间.
     */
    private $_updateAt;

    /**
     * 删除时间 0=未删除;大于0=删除时间;.
     */
    private $_deleteAt;

    /**
     * 创建账号.
     */
    private $_createAccount;

    /**
     * 更新账号.
     */
    private $_updateAccount;

    /**
     * Database connect.
     *
     * @var mixed
     */
    private static $connect;

    /**
     * Setter.
     *
     * @param mixed $value
     */
    public function setter(string $prop, $value): self
    {
        $this->{'_'.$this->realProp($prop)} = $value;

        return $this;
    }

    /**
     * Getter.
     *
     * @return mixed
     */
    public function getter(string $prop)
    {
        return $this->{'_'.$this->realProp($prop)};
    }

    /**
     * Set database connect.
     *
     * @param mixed $connect
     */
    public static function withConnect($connect): void
    {
        static::$connect = $connect;
    }

    /**
     * Get database connect.
     */
    public static function connect()
    {
        return static::$connect;
    }
}

酷毙

雷人

鲜花

鸡蛋

漂亮
  • 快毕业了,没工作经验,
    找份工作好难啊?
    赶紧去人才芯片公司磨练吧!!

最新评论

关于LUPA|人才芯片工程|人才招聘|LUPA认证|LUPA教育|LUPA开源社区 ( 浙B2-20090187 浙公网安备 33010602006705号   

返回顶部