php-crud-api icon indicating copy to clipboard operation
php-crud-api copied to clipboard

Suggestion: Make (middleware) config case-agnostic

Open nkappler opened this issue 3 years ago • 5 comments

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.

nkappler avatar Aug 05 '22 10:08 nkappler

Good issue. Might be better indeed, since environment parameters are not case sensitive either.

mevdschee avatar Aug 05 '22 18:08 mevdschee

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).

mevdschee avatar Aug 08 '22 21:08 mevdschee

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.

mevdschee avatar Aug 08 '22 21:08 mevdschee

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 🙂

nkappler avatar Aug 09 '22 08:08 nkappler

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...

nkappler avatar Aug 09 '22 08:08 nkappler