brefphp / laravel-bridge

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

Avoid fatal error when creating local directories #116

Closed deleugpn closed 1 year ago

deleugpn commented 1 year ago

As part of my migration to Bref v2, I stumbled on https://github.com/brefphp/laravel-bridge/issues/115. To solve the issue of the build server crashing with autoload, I changed my bootstrap/app.php file to invoke the StorageDirectories::create() function. This works on the build server and on Lambda, but crashes locally because the Bref::beforeStartup callback is never executed, so STDERR constant definition is never defined. Since this is just a helper output and not something critical, I thought we could get away by attempting to write to STDERR only if the constant has been defined so that it still works on local development without going through Bref startup while still making sure that the folders will be created

deleugpn commented 1 year ago

@mnapoli @tillkruss thoughts on this?