-
Notifications
You must be signed in to change notification settings - Fork 55
Description
Hey there, I'm quite new to Craft, so if this won't fit in the conventions, be free to close this issue.
Coming mainly from Laravel, the syntax to define endpoints seems a little off to me. I'd favor to use something like $api->addEndpoint(string $uri, Closure $handler);. On the one hand, that'd make IDE hints a tad more useful. On the other, it'd be nice to have a $api->addCollection(string $uri, Closure $endpointsCallback);, too. Within this $endpointsCallback, one could define additional endpoints sharing the collection URI as a prefix. That'd allow for conveniently splitting the elementapi.php into multiple files once the number of endpoints grows.
I've made a little proof of concept class which you'll find in in this gist, including usage examples. This could obviously be extended in functionality.
What's your opinion on this?