承接 rootdata21/hati 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

rootdata21/hati

最新稳定版本:v7.0.36-beta

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   |
                             /                 | :.       \     =\
                            ;                   \':.      /  ,-.__;.-;`

PHP Version Require Latest Stable Version Total Downloads License

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

  1. 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.
  2. 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.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固