We're using Bref to run a Laravel REST API on Lambda functions.
Everything works except now that we're trying to use Cognito. Particularly, we'd like to be able to handle Cognito's post confirmation event.
We are able to receive the event and read the data but we are having issues with loading Laravel or at least being able to call Laravel utilities (eg. AuthService.register()
) from the handler.
What we have so far:
// serverless.yml
functions:
postConfirm: app/Fns/PostConfirm.php
event:
- congitoUserPool:
pool: user-pool
trigger: PostConfirmation
existing: true
<?php
// .. snip for brevity
class PostConfirm implements \Bref\Event\Handler
{
public function handle ($event, \Bref\Event\Context $c)
{
$userAtt = $event['request']['userAttributes'];
// load laravel and call AuthService.register()
return $event;
}
}
return new PostConfirm();
I tried looking at the Sqs Handler in the bref/laravel-bridge
package but I honestly haven't done PHP for about 7 years, so it's a little difficult to follow.
If anyone could help me find the right documentation or point me in the right direction, that would be very much appreciated.
Thank you.
EDIT: To clarify, the question is how do we cleanly instantiate Laravel within this handler file?