brefphp / laravel-bridge

Package to use Laravel on AWS Lambda with Bref
https://bref.sh/docs/frameworks/laravel.html
MIT License
314 stars 63 forks source link

How Should I Load the framework for an Event Driven Function? #59

Closed kkobold closed 1 year ago

kkobold commented 2 years ago

What would be the best way to use laravel to write event driven function? Like, a trigger from an S3 or something?!

Thanks

deleugpn commented 2 years ago

You may be able to take a few inspiration from https://github.com/cgauge/laravel-bref-adapter/tree/master/handlers and https://blog.deleu.dev/using-aws-lambda-as-a-private-laravel-api/ Laravel has 2 primary entrypoint (public/index.php and artisan). Both of them reuses bootstrap/app.php for Application bootstrapping which is essential for any kind of outside bootstrapping. Once you have wrapped Laravel on a Bref callable you are free to run your event however it makes more sense (HTTP Request, Artisan Command or plain code execution).

mnapoli commented 1 year ago

With v2 of this bridge, you can now set a class name as a handler -> the service will be retrieved automatically from Laravel's container.

For example, for S3:

functions:
    queue:
        handler: App\MyS3Handler
        runtime: php-81
        events:
            -   s3: ...