php-crud-api
php-crud-api copied to clipboard
Suggestion: Make (middleware) config case-agnostic
There's probably no particular reason that middleware and other config options are case-sensitive.
I think it would be easier for inexperienced users, if this was made case-insensitive, as it might otherwise fail silently. The API will still work but the otherwise correctly spelled configuration might have no effect.
Good issue. Might be better indeed, since environment parameters are not case sensitive either.
I was thinking that maybe we should convert all config from 'camelCase' to 'snake_case', before making them case-insensitive. Maybe we can detect mixed case and convert (for legacy naming).
Thinking in a different direction: we could give appropriate error messages before executing the script for wrong case properties, so that they wont fail silently.
I don't really have an opinion on which option I prefer, but everything is better than failing silently 😅 However, while error messages can point the user in the right direction, the user then still needs to update the configuration and reupload the api to the server. If this is only caused by a case-inconsistency, it can be quite annoying, but could be easily avoided.
I think adding the error messages should be done in either case, but it should not be the only thing changed 🙂
I guess I slightly prefer my original proposal of keeping it camel-case but ignoring the case in addition to adding error messages, because I think it might be less work than switching to snake_case and it doesn't introduce a breaking change / the need for legacy support...