laravel-bridge
laravel-bridge copied to clipboard
How Should I Load the framework for an Event Driven Function?
What would be the best way to use laravel to write event driven function? Like, a trigger from an S3 or something?!
Thanks
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).
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: ...