The API example seems a bit weird once you learn about API generators such as API Platform (Symfony), which basically generates the whole thing the author talks about in a couple of commands.
Learning the right tools is an important part of being a high performing dev.