joindin/joindin-api

Move from JSON to PHP array for route declaration

Closed this issue · 1 comments

Yes, it's a minuscule performance improvement for what we're doing, but PHP arrays can be cached in opcache (and since the routes table is static it'll be cached once across all requests), while JSON blobs have to be read from disk every time. Would be easy enough to swap things over and we don't use the routes file in its JSON form anywhere else from what I can see.

We can also take that opportunity to provide a default base namespace for controllers. The PSR-4 changes make for quite a bit extra typing when building out additional routes.

The alternative would be to throw use statements at the top of the file and use ::class notation, which would have the added benefit of highlighting in an IDE if you typo a controller name.