gjerokrsteski/reactphp-pimf 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

gjerokrsteski/reactphp-pimf

Composer 安装命令:

composer require gjerokrsteski/reactphp-pimf

包简介

reactive RESTful API which uses ReactPHP and PIMF PHP micro framework

README 文档

README

This is an reactive RESTful API which uses ReactPHP and PIMF micro framework.

Build Status Code Climate

ReactPHP is one of the most promising libraries. It brings the powerful concept of event-driven, non-blocking I/O (Hi NodeJS) to PHP. With this technology in mind we are able to write our own HTTP stack in PHP and have control back over the memory without destroying it at the end of each request.

ReactPHP is responsible for establishing the TCP-Socket, transferring the raw HTTP Requests and sending the HTTP Responses back.

PIMF micro framework is responsible for managing the HTTP Resources using the HTTP request methods, validation and handling the persistence interactions.

Benchmark Results, over 19500 requests completed per second

[vagrant@gkrsteski php-reactor]$ loadtest http://10.0.49.227:5501/articles/10 -t 20 -c 20 --rps 1000
[Wed Feb 10 2016 12:24:47 GMT+0100 (CET)] INFO Requests: 0, requests per second: 0, mean latency: 0 ms
[Wed Feb 10 2016 12:24:52 GMT+0100 (CET)] INFO Requests: 4516, requests per second: 903, mean latency: 10 ms
[Wed Feb 10 2016 12:24:57 GMT+0100 (CET)] INFO Requests: 9515, requests per second: 1000, mean latency: 0 ms
[Wed Feb 10 2016 12:25:02 GMT+0100 (CET)] INFO Requests: 14515, requests per second: 1000, mean latency: 10 ms
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO Target URL:          http://10.0.49.227:5501/articles/10
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO Max time (s):        20
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO Concurrency level:   20
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO Agent:               none
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO Requests per second: 1000
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO Completed requests:  19512
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO Total errors:        0
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO Total time:          20.000516531000002 s
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO Requests per second: 976
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO Total time:          20.000516531000002 s
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO Percentage of the requests served within a certain time
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO   50%      2 ms
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO   90%      9 ms
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO   95%      18 ms
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO   99%      30 ms
[Wed Feb 10 2016 12:25:07 GMT+0100 (CET)] INFO  100%      36 ms (longest request)

Installation

  1. clone this repository
  2. run: ./init-app.sh

Run using PHP

php run-server.php

Or run with Docker

Build a Docker image for your application by running:

docker build -t="reactphp-pimf-api" .

Finally, run your application as a Docker container by running:

docker run -d -p 1337:1337 reactphp-pimf-api

Try out the RESTful API

  • http://{reactive.hosts}:{reactive.port}/articles/
  • use HTTP method OPTIONS to find how to use the API

Expected API behavior for resource: /articles

HTTP Verb |  Entire Collection (e.g. /articles)                                          | Specific Item (e.g. /articles/{id})
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
GET       | 400 (Bad Request)                                                            | 200 (OK), single article.
          |                                                                              | 404 (Not Found), if ID not found or 400 (Bad Request) if invalid.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
PUT       | 405 (Method Not Allowed)                                                     | 200 (OK),
          | - unless you want to update/replace every resource in the entire collection. | 404 (Not Found) if ID not found or 400 (Bad Request) if invalid.
          | - 'Location' header with link to API documentation                           |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
POST      | 201 (Created),                                                               | 405 (Method Not Allowed)
          | - 'Location' header with link to /articles/{id} containing new ID.           | - 'Location' header with link to API documentation
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
DELETE    | 404 (Not Found) or 405 (Method NOt Allowed)                                  | 200 (OK)
          | - unless you want to delete the whole collection—not often desirable.        | 404 (Not Found) if ID not found or 400 (Bad Request) if ID invalid.
          | - 'Location' header with link to API documentation                           |


Run tests

Install a Composer to your project's root

php composer.phar require "codeception/codeception:*"
// or ...
composer require "codeception/codeception:*"

Execute tests

php vendor/codeception/codeception/codecept run --colors
// or if want to see steps ...
php vendor/codeception/codeception/codecept run --steps
// or if want to see fancy HTML report page
php vendor/codeception/codeception/codecept run --html

gjerokrsteski/reactphp-pimf 适用场景与选型建议

gjerokrsteski/reactphp-pimf 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 26, 最近一次更新时间为 2017 年 01 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 gjerokrsteski/reactphp-pimf 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 gjerokrsteski/reactphp-pimf 我们能提供哪些服务?
定制开发 / 二次开发

基于 gjerokrsteski/reactphp-pimf 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 26
  • Watchers: 5
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2017-01-05