22 ms·
> People still largely seem to use require() and include() statements everywhere in their code. What. The. Fudge. I'm one of the people who like to have requir
by toast0 9y ago
> People still largely seem to use require() and include() statements everywhere in their code. What. The. Fudge.
I'm one of the people who like to have require (with full paths too, if we can). Looking at the code, I can see what it needs and where it gets it; I don't have to reverse engineer what the autoloader will do; I don't have to wonder how many system calls it's going to take for it to do it.
Async can be nice, but the language contortions you need to go through to get it are painful. If you can stuff your database calls into webservices, you can use curl_multi to do parallel fetches everything you need and let the database webservices run the queries single threaded in lots of different processes. It adds a layer, but it's easy to understand.
In my opinion the right way to write PHP is embrace the PHP serving model: at the beginning, you get a request, you return back something (html, whatever), and then everything in memory is thrown away. Because everything is going to be thrown away in a little bit, it doesn't make sense to invest in a delightful hierarchy of classes; just parse the input, grab the right data, and stuff it together in as little code as possible.