beyondcode / laravel-server-timing

Add Server-Timing header information from within your Laravel apps.
MIT License
552 stars 43 forks source link

Enable Flag from ENV Var #11

Closed nhalstead closed 8 months ago

nhalstead commented 4 years ago

This update allows for control of it's enable state. I think this should be something included out of the box, I know its a simple change but its something that I think it's helpful as lots of things are controlled via ENV vars in the end.

I have it reading the ENV Value and checking if its string(true), if so then true otherwise false. If no value is passed in then it defaults to true anyway so its the same result as if this was not added in.

nhalstead commented 4 years ago

I also had thought of using filter_var but I think it's a bit overboard for validation of value but allows for "1", "yes", "true", "on", all of the 'non-standard' enable keywords for env var values.

filter_var(env('ENABLE_SERVER_TIMING', 'true'), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ?? true,