【问题标题】:Serverless framework, handler doesn't exists无服务器框架,处理程序不存在
【发布时间】:2020-06-02 04:34:37
【问题描述】:

我正在使用无服务器框架在 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 功能正常。

【问题讨论】:

    标签: php amazon-web-services aws-lambda serverless-framework serverless


    【解决方案1】:

    我看到您在 serverless.yml 文件中添加了处理程序作为 handler: public/index.php,但您的文件名为 test.php。在我看来,这是一个打字错误。

    【讨论】:

      猜你喜欢
      • 2022-01-11
      • 2021-11-24
      • 2022-07-26
      • 2020-10-22
      • 2021-04-07
      • 1970-01-01
      • 1970-01-01
      • 2022-06-14
      • 1970-01-01
      相关资源
      最近更新 更多