简体   繁体   English

使用 websockets 通过 AWS API 网关接收请求并使用 AWS Lambda 调用 php 脚本

[英]Receive a request through AWS API Gateway using websockets and invoke a php script using AWS Lambda

Kinda lost on which services do I need to use, the idea is to build a server-less application using AWS services, here's a more detailed explanation on I'm looking for:我有点迷失了我需要使用哪些服务,这个想法是使用 AWS 服务构建一个无服务器应用程序,这是我正在寻找的更详细的解释:

  1. Client sends a request using websockets.客户端使用 websockets 发送请求。
  2. AWS API Gateway receives the request and invokes a lambda function. AWS API 网关接收请求并调用 lambda function。
  3. The lambda function runs a php worker using Bref ( https://bref.sh/ ). lambda function 使用 Bref ( Z5E056C500A1C4B6A7110B ) 运行 php 工作程序。
  4. The php worker requires another php file which connects to a 3rd party using HTTP to request data (we have several of these so we're going to wake several workers probably for 1 single request from the client). php 工作人员需要另一个 php 文件,该文件使用 HTTP 连接到第三方以请求数据(我们有几个这样的 1 个请求,因此我们将唤醒来自客户端的多个工作人员)。
  5. The data obtained is returned all the way back to the client.获取的数据一路返回给客户端。

So what I want to accomplish is to avoid using HTTP until point 5, now I'm totally lost in regards to this being doable or not, where do I host my php files?所以我想要完成的是避免使用 HTTP 直到第 5 点,现在我完全不知道这是否可行,我在哪里托管我的 php 文件? do I need to use AWS SQS to invoke the lambda function?我是否需要使用 AWS SQS 来调用 lambda function?

Any help would be appreciated guys, trying to ready through the official Amazon documentation is quite complex.任何帮助将不胜感激,尝试通过亚马逊官方文档进行准备非常复杂。

AWS Lambda Function is essentially a container that runs on a certain runtime. AWS Lambda Function 本质上是一个运行在某个运行时的容器。

Since PHP is not supported as an out-of-the-box runtime, you'll have to use a custom runtime.由于不支持 PHP 作为开箱即用的运行时,因此您必须使用自定义运行时。

Here's a great example by AWS for creating a Layer for PHP - https://github.com/aws-samples/php-examples-for-aws-lambda/tree/master/0.1-SimplePhpFunction这是 AWS 为 PHP - https 创建层的一个很好的示例://github.com/aws-samples/php-examples-for-aws-lambda/tree/master/0.1-SimplePhpFunction

Another example, this one is for creating a custom runtime for PHP by using Docker - https://github.com/aws-samples/php-examples-for-aws-lambda/tree/master/0.7-PHP-Lambda-functions-with-Docker-container-images另一个示例,此示例用于通过使用 Docker - https://github.com/aws-Lambda-samples//php-master/aws-PHP-samples/function- -with-Docker-container-images

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM