Don't read the `config/pushnotification.php` file directly
trevorgehman opened this issue · comments
Currently, when the config is being generated, it is doing this:
PushNotification/src/PushService.php
Lines 66 to 69 in da8763a
This is not good practice. You should be accessing the cached config values instead, something like this:
$configuration = app('config')->get('pushnotification');
Not only is the performance much better, but you can run into issues (as I did) if you are setting config options using environment variables, like this:
'apn' => [
...
'dry_run' => env('APP_ENV') === 'local' ? false : true,
],
The reason is because those env()
calls will return null
after the configuration has been cached:
Caching And Env
If you are using the config:cache command during deployment, you must make sure that you are only calling the env function from within your configuration files, and not from anywhere else in your application.
If you are calling env from within your application, it is strongly recommended you add proper configuration values to your configuration files and call env from that location instead, allowing you to convert your env calls to config calls.
Hi @trevorgehman ,
Thanks for noticing that. I will review so and update the package accordingly to best practice.
Thanks @trevorgehman :)