定制 aphpi-core/aphpi 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

aphpi-core/aphpi

最新稳定版本:0.0.1

Composer 安装命令:

composer require aphpi-core/aphpi

包简介

a micro PHP API router framework

README 文档

README

a micro PHP API router framework

api example

<?php

require '../src/APhpI.php';
use APhpI\APhpI;

// set verbose error reports ...
APhpI::set_error_handling_env("dev");

// init API router ...
$api=new APhpI;

$api->add_route('get','/info', function($event) {
	return array(
		'statusCode'=>200,
		'headers'=> array(
			'Content-type'=>'application/json'
		),
		'body'=>var_export($event, true)
	);
});

$api->add_route('post','/echo', function($event) {
	return array(
		'statusCode'=> 200,
		'body'=> $event['body']
	);
});

$api->add_route('get','/user/:user', function($event) {
	$user=$event['url_params']['user'];
	return [
		'statusCode'=>200,
		'body'=> "your user url param is $user ."
	];
});

$api->add_route('get','/user2', function($event) {
	$user=$event['get_params']['user'];
	return [
		'statusCode'=>200,
		'body'=> "your user url param is $user ."
	];
});

$api->run();

run test server

make run_dev

exmaple test

~ % curl http://localhost:3000/api.php/echo -X POST -d 'foo' -i
HTTP/1.1 200 OK
Host: localhost:3000
Date: Mon, 28 Oct 2019 17:05:32 +0000
Connection: close
X-Powered-By: PHP/7.1.23
Content-type: text/html; charset=UTF-8

foo

~ % curl http://localhost:3000/api.php/info -i
HTTP/1.1 200 OK
Host: localhost:3000
Date: Fri, 06 Feb 2026 21:49:14 GMT
Connection: close
X-Powered-By: PHP/8.5.2
Content-type: application/json

{"headers":{"Host":"localhost:3000","User-Agent":"curl/8.18.0","Accept":"*/*"},"get_params":[],"url_params":[],"body":"","method":"GET","request_path":"/info"}

~ % curl http://localhost:3000/api.php/user -i
HTTP/1.1 200 OK
Host: localhost:3000
Date: Mon, 28 Oct 2019 17:09:44 +0000
Connection: close
X-Powered-By: PHP/7.1.23
Content-type: text/html; charset=UTF-8

404 not found

~ % curl http://localhost:3000/api.php/user/1234 -i
HTTP/1.1 200 OK
Host: localhost:3000
Date: Mon, 28 Oct 2019 17:09:50 +0000
Connection: close
X-Powered-By: PHP/7.1.23
Content-type: text/html; charset=UTF-8

your user url param is 1234 .

~ % curl http://localhost:3000/api.php/user2\?user\=1234 -i
HTTP/1.1 200 OK
Host: localhost:3000
Date: Mon, 28 Oct 2019 17:10:51 +0000
Connection: close
X-Powered-By: PHP/7.1.23
Content-type: text/html; charset=UTF-8

your user url param is 1234 .

licence: L-Beerware

The L-Beerware license PREAMBLE: L-Beerware (also known as LBeerware or lbeerware) is a lesser Beerware license originally written by Poul-Henning Kamp.

LICENSE:

/*
 * ----------------------------------------------------------------------------
 * "THE L-BEERWARE LICENSE" (Revision 48):
 * This stuff comes with NO WARRANTY. As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy the author a beer in return.
 * ----------------------------------------------------------------------------
 */

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Beerware
  • 更新时间: 2026-02-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固