QueryPHP V1-beta.1 部分文档代码解耦,版本 PHP 7.3.2

2019-04-15 11:35:42 +08:00
 doyouhaobaby

经过 1 个月的开发,QueryPHP v1.0.0-beta.1 版本可以发布了,这也是 beta 3 个版本的开始部分。这个版本的主要是代码解耦和性能提升,文档开发。

关于 QueryPHP

QueryPHP 是一款现代化的高性能 PHP 7 常驻框架,以工程师用户体验为历史使命,让每一个 PHP 应用都有一个好框架。

百分之百单元测试覆盖直面 Bug 一剑封喉,基于 Zephir 实现框架常驻,依托 Swoole 生态实现业务常驻,此刻未来逐步渐进。 我们的愿景是 USE LEEVEL WITH SWOOLE DO BETTER, 让您的业务撑起更多的用户服务。

更新日志

函数惰性加载

PHP 的函数式特性已经逐步被纯对象所取代,函数库很多时候被包装为静态类,很多时候其实不需要一个类,为此 QueryPHP 底层框架提供了全局函数 fn 来实现了惰性加载。

<?php

declare(strict_types=1);

fn('Leevel\\Support\\Str\\rand_num', 5);

精简框架自身助手函数库

仅仅提供 4 个助手函数就完全满足了系统的库函数的加载使用。

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

fn('Leevel\\Support\\Str\\rand_num', 5); 
hl('dump', 1, 2);
app('request');
__('国际化');

例子函数

<?php

declare(strict_types=1);

namespace Leevel\Support\Str;

/**
 * 随机数字.
 *
 * @param int    $length
 * @param string $charBox
 *
 * @return string
 */
function rand_num(int $length, ?string $charBox = null): string
{
    if (!$length) {
        return '';
    }
    if (null === $charBox) {
        $charBox = '0123456789';
    }
    return rand_str($length, $charBox);
}

// @codeCoverageIgnoreStart
if (!function_exists('Leevel\\Support\\Str\\rand_str')) {
    include __DIR__.'/rand_str.php';
}
// @codeCoverageIgnoreEnd

Facade 优化

最开始采用的 Laravel 的继承一个基础的 Facade,方便单元测试,有一定性能损失。后来觉得在做单元测试只需要清空容器注册的服务就可以所以优化了一版本。

<?php

declare(strict_types=1);

namespace Leevel\Encryption\Facade;

use Leevel\Leevel\App;

/**
 * 门面 encryption.
 *
 * @author Xiangmin Liu <635750556@qq.com>
 *
 * @since 2017.06.10
 *
 * @version 1.0
 */
class Encryption
{
    /**
     * call.
     *
     * @param string $method
     * @param array  $args
     *
     * @return mixed
     */
    public static function __callStatic(string $method, array $args)
    {
        return App::singletons()
            ->make('encryption')
            ->{$method}(...$args);
    }
}

文档更新

系统新增了 20 个新的文档,后续会逐渐丰富起来。

https://www.queryphp.com/docs/

自动载入优化器

QueryPHP 实现了一套基于并且优化了 composer 的自动加载,并且屏蔽了助手函数的载入。

这次提供了白名单来让你选择部分函数的载入。

/**
 * ---------------------------------------------------------------
 * Composer
 * ---------------------------------------------------------------.
 *
 * 用于管理 PHP 依赖包
 * 优化 composer 性能,提炼 composer 中的 autoload_static 中的我们关注的 psr4 命名空间映射
 * 我们 classmap 需要通过 `php leevel autoload` 生成,包含命令 `composer dump-autoload -o`
 * 对于助手函数需要自己引入
 */
$autoloadLeevel = __DIR__.'/../vendor/autoloadLeevel.php';

if (is_file($autoloadLeevel)) {
    $composer = require $autoloadLeevel;
} else {
    $composer = require __DIR__.'/../vendor/autoload.php';
}

composer.json 部分代码

{
    "name": "hunzhiwange/queryphp",
    "description": "The QueryPHP Application.",
    "require": {
        "php": "^7.3.2",
        "hunzhiwange/framework": "dev-master"
    },
    "extra": {
        "leevel-console" : {
            "autoload": {
                "@namespaces": "The white of Psr4",
                "namespaces": [
                    "Leevel",
                    "Dotenv",
                    "Carbon",
                    "Monolog",
                    "Whoops",
                    "Swagger"
                ],
                "@files": "The white of autoload files",
                "files": [
                    "common/Infra/functions.php",
                    "hunzhiwange/framework/src/Leevel/Leevel/functions.php"
                ]
            }
        }
    }
}

更好地领域驱动分层实现,工作流支持

正在尝试更好地代码实现领域驱动设计分层架构。

https://github.com/hunzhiwange/queryphp/blob/master/common/Domain/Service/User/Role/Update.php

锁定部分组件版本

锁定 doctrine/annotations ~1.6.0 和 zendframework/zend-diactoros ^2.1.1 减少兼容性问题和修复用户安装报错的问题,持续集成系统在 composer 最低依赖状况下不会出错。

https://github.com/hunzhiwange/queryphp/issues/1

帮助我们

QueryPHP 是在 2016 年 10 月开始基于一个我早年的 PHP 框架 DoYouHaoBaby 框架开发的。这个早年的框架是我在 2010 年 7.8 月开始的,那个时候在大二,开始的框架也主要用于自用。早年基于这个框架的一些应用作品如下:

DYHB.BLOG_X

DYHB.BLOG_X-2.0 详细安装图文教程 http://www.knowsky.com/804758.html

http://www.downcode.com/downcode/j_18106.shtml

https://github.com/hunzhiwange/dyhb.blog-x

WindsForce 社区

http://www.mycodes.net/code_previewmap.php?id=6185

https://github.com/hunzhiwange/windsforce

https://www.oschina.net/p/windsforce

目前 QueryPHP 由本人一人负责开发,文档,logo 设计,视频,官网和宣传需要大量精力。

如果你觉得可以,可以推荐朋友来试用一下,关注一哈,希望吸引到有兴趣的一起开发,文档,。

用 10 年打造一个完美的作品,2010-present Xiangmin Liu。

2775 次点击
所在节点    PHP
3 条回复
vst93
2019-04-15 12:13:35 +08:00
一个人专注于一个产品值得敬佩,加油
rookies
2019-04-15 14:10:12 +08:00
敬佩
NjcyNzMzNDQ3
2019-04-15 16:57:40 +08:00
支持,已 start

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/555254

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX