php - 无服务器框架,处理程序不存在
问题描述
我正在使用无服务器框架在 AWS Lambda 上部署我的 PHP 函数。我试过一个简单的例子,但我可以在 cloudwatch 里面看到这个错误:
Handler `/var/task/public/test.hello` doesn't exist
这是我的无服务器文件:
service: symfony-bref
provider:
name: aws
region: eu-central-1
runtime: provided
environment:
APP_ENV: prod
plugins:
- ./vendor/bref/bref
functions:
api:
handler: public/index.php
description: ''
timeout: 30 # in seconds (API Gateway has a timeout of 30 seconds)
layers:
- ${bref:layer.php-73-fpm}
events:
- http: 'ANY /'
- http: 'ANY /{proxy+}'
S3Handler:
handler: public/test.hello
layers:
- ${bref:layer.php-73}
events:
- s3:
bucket: ${ssm:/symfony-bref/AWS_S3_BUCKET_NAME:1}
event: s3:ObjectCreated:*
existing: true
我的函数 test.php 在 public 文件夹中:
<?php
function hello($eventData) : array
{
return ["msg" => "hello from PHP " . PHP_VERSION];
}
我可以为函数 S3Handler 做什么?Api 功能运行良好。
解决方案
我看到您在 serverless.yml 文件中添加了处理程序作为处理程序:public/index.php,但您的文件名是 test.php。在我看来,这就像一个打字错误。
推荐阅读
- python-3.x - 在Python中在偶数x轴上不均匀地绘制多个箱形图
- android - 了解 Flutter 依赖和 Build.gradle 关系
- c# - 无法使用 .NET 5 中的 JsonSubTypes 反序列化 WebApi 中的 Json,尽管能够在控制台应用程序中
- javascript - 如何使用 React Hooks 编写删除处理函数?
- email - 如何通过 Postfix SMTP 服务器发送自定义传递状态通知?
- android-studio - 如何在kotlin android studio“时间前”计算月份和年份
- c++ - 为单例声明 const 静态方法以不更改成员变量
- python - 如何根据包含初始和最终索引的 2 个 1D 数组对 2D numpy 数组进行切片
- android - 为一次性短信代码计算 Android 应用程序哈希键
- google-apps-script - 在最后一个空行上附加新记录(而不是忽略最后一个空行并在工作表末尾添加新行)