If you go the 1 class-1 file route, the file feels kinda redundant.
Redundant? On the contrary I think. It results in less redundancy, or at least less overhead.
I’m curious: Is the overhead of managing of the mapping file a lot less than including what you don’t need? Did you do any benchmarking on that
In my experience yes. The more atomic you can make a file, the less overhead is a direct result.
If you keep several classes in one file there will almost always come a time where you need only a single class but including the file results in bringing in extra baggage.
I’m imagining that the mapping file could grow quite large on a somewhat large project?
If you insist on going with the mapping file, sure of course it could. The alternative is to base your class names on some convention to automate lookup and loading. Much like Zend or PEAR.
There was a time (several years ago) where I believed that having a naming scehme like PEAR or Zend was bad practice because of the coupling between directory structure and class name, one dictating the other or vis-versa. However after experimenting with both I eventually determined the benefits out-weighed the negatives.
It does require more though and planning go into your directory structure, but then again, that is not nessecarily a bad thing… It simply means you cannot create files willy-nilly like most developers seem to do.
IMO it forces cleaner code base and directory structure.
In the end, I don’t like the magic involved. An include/require[_once] makes things nice and clear, it’s explicit
That was part of my argument as well, however, implicit is not evil in it’s own, magic is only bad when it’s just that, magic. If others cannot understand how classes are bring loaded then I would say its a bad thing. However if you clearly document or make clear to new developers how an automation happens, then it no longer is magic, it
s convention.
Cheers,
Alex