As someone who has written a lot of PHP and is still maintaining a few PHP codebases... I don't miss the old ways at all. But I can see how the parent comment can be misleading for someone who's not too familiar with PHP (apologies if my assumption is wrong).
TL;DR in many ways modern PHP is more explicit than old PHP
The old way wasn't as explicit as the comment makes it. It was just painful. Imports in PHP are global, so every file can use any function/class already imported. You could explicitly define all dependencies at the top, but that's not what the language shepherds you to. In reality most imports were implicit (explicit in ANOTHER file), and you'd just import what you needed that hadn't been already imported (I don't think I've ever worked in a codebase where every file has all dependencies declared at the top). The old ways had so many downsides:
- moving things around could produce fatal errors just because the implicit imports changed
- any framework/cms using require instead of requice_once would limit your ability to import files (including the same class twice creates a fatal error)
- very poor support for IDEs
The modern way is quite pleasant to work with:
- everything should be in a namespace
- every used class should be declared at the top of the file (like Java)
- great IDE support (auto imports, auto complete, click to go to definition)
Yes there's some extra complexity in the autoloader, but in my experience it's negligible. If you use an IDE you might never even see it.
So yeah I don't think PHP got any less explicit. The opposite actually, modern libraries/frameworks tend to be much easier to navigate.
Yeah, my explanation wasn't good. Yours is much better – thanks!
If anyone's curious what the old way looks like, have a look at WordPress's codebase – lots of imports scattered around everywhere with no one single class-loading system.
TL;DR in many ways modern PHP is more explicit than old PHP
The old way wasn't as explicit as the comment makes it. It was just painful. Imports in PHP are global, so every file can use any function/class already imported. You could explicitly define all dependencies at the top, but that's not what the language shepherds you to. In reality most imports were implicit (explicit in ANOTHER file), and you'd just import what you needed that hadn't been already imported (I don't think I've ever worked in a codebase where every file has all dependencies declared at the top). The old ways had so many downsides:
- moving things around could produce fatal errors just because the implicit imports changed
- any framework/cms using require instead of requice_once would limit your ability to import files (including the same class twice creates a fatal error)
- very poor support for IDEs
The modern way is quite pleasant to work with:
- everything should be in a namespace
- every used class should be declared at the top of the file (like Java)
- great IDE support (auto imports, auto complete, click to go to definition)
Yes there's some extra complexity in the autoloader, but in my experience it's negligible. If you use an IDE you might never even see it.
So yeah I don't think PHP got any less explicit. The opposite actually, modern libraries/frameworks tend to be much easier to navigate.