I'm using laravel 8 and bref to deploy it on lambda. After making a cron job function to send email. When I deploy it, there's a problem with the facade
{
"errorType": "RuntimeException",
"errorMessage": "A facade root has not been set.",
"stackTrace": [
"#0 /var/task/app/functions/sendTestMail.php(11): Illuminate\\Support\\Facades\\Facade::__callStatic()",
"#1 /var/task/vendor/bref/bref/src/Runtime/Invoker.php(34): Bref\\Runtime\\FileHandlerLocator->App\\Functions\\{closure}()",
"#2 /var/task/vendor/bref/bref/src/Runtime/LambdaRuntime.php(102): Bref\\Runtime\\Invoker->invoke()",
"#3 /opt/bref/bootstrap.php(43): Bref\\Runtime\\LambdaRuntime->processNextEvent()",
"#4 {main}"
]
}
here is my directory structure and the function: sendTestMail.php
serverless.yml:
service: test
provider:
name: aws
# The AWS region in which to deploy (us-east-1 is the default)
region: ap-southeast-1
# The stage of the application, e.g. dev, production, staging… ('dev' is the default)
stage: dev
runtime: provided.al2
package:
# Directories to exclude from deployment
exclude:
- node_modules/**
- public/storage
- resources/assets/**
- storage/**
- tests/**
functions:
# This function runs the Laravel website/API
web:
handler: public/index.php
timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
layers:
- ${bref:layer.php-80-fpm}
events:
- httpApi: "*"
# This function lets us run artisan commands in Lambda
artisan:
handler: artisan
timeout: 120 # in seconds
layers:
- ${bref:layer.php-80} # PHP
- ${bref:layer.console} # The "console" layer
cron:
handler: app/functions/sendTestMail.php
layers:
- ${bref:layer.php-80}
events:
- schedule: rate(5 minutes)
plugins:
# We need to include the Bref plugin
- ./vendor/bref/bref
Anyone know how to resolve this issue? And btw, how can I test a handler function on my local machine before deploying? Thank you