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

Option to not run config:cache? #105

Closed sunaoka closed 1 year ago

sunaoka commented 1 year ago

Could there be an option to not run config:cache?

We are a development locally using bref/php-*-fpm-dev:2. Every time we change the .env, we have to restart the docker container, which is very tedious.

georgeboot commented 1 year ago

First reaction is that config cache and other optimisations, should not happen during local dev. But on the other hand, one should be able to replicate full prod setup locally.

So that probably means we should be able to (optionally?) disable this behaviour locally. @tillkruss what's your feeling on this?

mnapoli commented 1 year ago

If needed, we could set an env variable in the -dev images to signal it's a dev image.

Do you think there are other behaviors like these that we wouldn't want to reproduce when developing locally?

But on the other hand, one should be able to replicate full prod setup locally.

Oh, maybe one option is to enable/disable these behaviors based on the APP_ENV of Laravel? (and not based on the Docker image)

georgeboot commented 1 year ago

Oh, maybe one option is to enable/disable these behaviors based on the APP_ENV of Laravel? (and not based on the Docker image)

Yeah sounds good. Maybe even something like:

$shouldCache = env('BREF_LARAVEL_CACHE_CONFIG', env('APP_ENV') === 'production')
// or
$shouldCache = env('BREF_LARAVEL_CACHE_CONFIG', env('APP_ENV') !== 'local')
mnapoli commented 1 year ago

Sounds like an even better idea! (the second one sounds better I think because you could deploy "staging" environments for example)

tillkruss commented 1 year ago

Yeah, I'd agree that routes and the config doesn't need to be cached in dev. You can also use App::environment('local') for testing it, if needed @mnapoli.

sunaoka commented 1 year ago

Is there an update on this case?

$shouldCache = env('BREF_LARAVEL_CACHE_CONFIG', env('APP_ENV') ! == 'local')

Can I create a PR using the following?

mnapoli commented 1 year ago

@sunaoka hi! Yes feel free to create a PR!