rootdata21/hati
Composer 安装命令:
composer require rootdata21/hati
包简介
Hati - A powerful PHP library written in PHP 8 with various library functions and classes to make API or App development effortless.
README 文档
README
.'``'.__
/ \ `'"-,
.-''''--...__..-/ . | \
.' ; :' '. a |
/ | :. \ =\
; \':. / ,-.__;.-;`
Welcome to the Hati wiki! Hati is a powerful PHP library written in PHP 8 which has various library functions and classes to make API or application development in PHP effortless. This library has great support for crafting:-
- APIs development support
- Form data & request validations
- Basic Template engine
- Email functions [using PHPMailer]
- Easy file uploading
- Multiple database operations
- Simplistic Date-Timing functions
- Number crunching utility functions etc.
- Zip files creation
Hati utilizes composer autoload. You can use apache's dot htaccess file to prepend the Hati init file which will require 'vendor/autoload.php' behind the scene to resolve the loader dependencies. Many aspect of Hati can be configured by using the configuration files found on project root hati/hati.json & hati/db.json.
Hati comes with a few tools which are found on the project root's hati/tool folder. These tools are used to help working with multiple database, API documentation etc.
Library functions, class names are inspired by Bengali language. Many common words from Bengali language such Kuli, Biscut, Shomoy are found within this library.
Install
Install the latest version using:
composer require rootdata21/hati
Or add to your composer.json file as a requirement:
{
"require": {
"rootdata21/hati": "~5.0.0"
}
}
Setup
- Hati can only be used in PHP 8 or above. In order to set up the Hati, you can use the htaccess file provided with the library to prepend the "hati/init.php" file or manually require it using require function.
- Adjust the "hati/hati.json" file to configure the environment.
Demo
Below an API is written using Fluent class to perform database query where sql is prepared and behind the scene and the result is fetched using datum method. With traditional approach such task would take up to 10 lines. Hati really shrinks down the line of code you have to write over and over again. Finally, it return the output as JSON to requester.
<?php /* * Register the API in the "api/hati_api_registry.php" file using * HatiAPIHandler::register method. */ \hati\Api\HatiAPIHandler::register([ 'method' => 'GET', 'path' => 'welcome/get', 'handler' => 'v1/ExRate.php', 'description' => 'A GET API' ]); // Use a specific database connection Fluent::use(DBPro::exampleDb); // search the name by id from the database table using PDO extension $id = 5; Fluent::exePrepared("SELECT name FROM user WHERE user.id = ?", [$id]); // get the name value from the select statement with simple datum method $name = Fluent::datum('name'); // craft and reply JSON output $response = new Response(); $response -> add('name', $name); $response -> reply('Operation has been done', header: [ 'X-EXAMPLE-HEADER: SOMETHING', 'Content-Type: application/json' ]);
Output
Hitting the API at: https://example.com/api/welcome/get
{
"name": "Abdul Ahad",
"response": {
"status": 1,
"msg": "Operation has been done"
}
}
License
This project is maintained under MIT license.
rootdata21/hati 适用场景与选型建议
rootdata21/hati 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 467 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 06 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「library」 「php8」 「hati」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rootdata21/hati 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rootdata21/hati 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rootdata21/hati 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
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
统计信息
- 总下载量: 467
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-25