thazh/api-light
最新稳定版本:1.0.0
Composer 安装命令:
composer require thazh/api-light
包简介
A lightweight library is used to build a secure REST API in PHP.
关键字:
README 文档
README
A lightweight library is used to build a secure REST API in PHP.
Features
The main features provided by this library are:
- Easy to use
- Support all the PHP versions
- Required field validation
- Basic authentication
- Support multiple content types
- Support all the request methods
Quick Start
Install the library using composer:
composer require thazh/api-light
A sample PHP API to validate and process the input data and print the response data
<?php use Thazh\ApiLight\RestApi; $options = array( 'content_type' => 'application/json', 'request_method' => 'POST', 'credentials' => array( 'testuser' => 'TestPwd@123', ), 'required_fields' => array( 'rollno', 'name', ) ); $obj = new RestApi($options); /* Custom business logic */ $output_data = "Hi, " . $obj->request['name'] . "! Your roll no is " . $obj->request['rollno']; /* Set code 200 for the success response */ $obj->code = 200; /* Set API response data */ $obj->data = $output_data; /* Print the API response data */ $obj->print();
Post parameters:
{
"rollno": 10001,
"name": "Saravanan S"
}
The above sample PHP API outputs the below response
{
"code": 200,
"status": "success",
"data": "Hi, Saravanan S! Your roll no is 10001"
}
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-17