laravel-bridge icon indicating copy to clipboard operation
laravel-bridge copied to clipboard

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

Open kkobold opened this issue 3 years ago • 1 comments
trafficstars

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

Thanks

kkobold avatar Dec 23 '21 17:12 kkobold

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).

deleugpn avatar Mar 09 '22 21:03 deleugpn

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: ...

mnapoli avatar Mar 20 '23 14:03 mnapoli