Creating a Simple REST API

So I am trying to create a API for my ReactJS website.

I searched on Google to find the tutoriel "Creating a Simple REST API"

However, I have ALOT of diffrent routes, and it seems like alot of code to put like 50 routes into the index file.

Is there any other way to structur the code, so that i have to have a file for every section, like "Posts" and "Pages" So "/api/posts" and "/api/pages"

Hope you understand!

In medium applications you can organize handlers in controllers.

https://docs.phalconphp.com/en/3.4/application-micro#routing-handlers-controllers