waryway/micro-service-engine

适用于微服务应用的 ReactPHP 服务器

1.0.6 2021-03-30 20:32 UTC

This package is auto-updated.

Last update: 2024-09-04 14:47:35 UTC


README

仅使用 ReactPHP 的 PHP 微服务基础服务

状态

Build Status

描述

使用这个微服务引擎来驱动你的微服务!它是一个可扩展的 ReactPHP 路由/服务器基础。

我能想到的最接近的比较是 Node.js 的 express。只是,这个是用 PHP 编写的!

用法

启动此服务的粗略步骤。示例即将推出!

  1. 创建新的 PHP 微服务应用程序
  2. 确保它是 PSR-4 标准
  3. 在基础命名空间中添加一个 Router 类。
  4. 命名空间应该是类似于... <项目>
  5. 运行 composer update
  6. 'composer require waryway/micro-service-engine'
  7. 在新项目的根目录中,只需运行: vendor\bin\server.bat <公司>\<项目> 0.0.0.0:99
  8. 或者对于 Linux: ./vendor/bin/server <公司>/<项目> 0.0.0.0:99

您也可以运行 vendor\bin\server.bat -h 获取更多信息。

路由设置

请确保扩展 BaseRouter。更多详细信息将在未来添加!

设置路由

微服务引擎使用 nikic/fast-route 库。您可以在 nikic/fast-route 的 README 中找到路径映射信息。

示例路由器

示例应用程序

https://github.com/Waryway/MicroServiceEngine/blob/master/example/Router.php

内部示例

对于这个存储库,您可以通过首先运行 computer install,然后运行

php server Waryway\Example 0.0.0.0:89

您将能够访问 localhost:89/index.htmllocalhost:89/hi