Autoloading: it's like plumbing. You forget it's there, but when it's gone,
well, let's just say you have to go outside a bit more often.
Autoloading is the magic that lets us use classes without needing to require
or include the file that holds them first. We used to have include
statements everywhere, and well, it was terrible.
But an autoloader has a tricky job: given any class name, it needs to know
the exact location of the file that holds that class. In many modern projects,
including ours, Composer handles this, and there are two pieces to understanding
how it figures out what file a class lives in.
When we create an Event object, Composer's autoloader knows that this class
lives inside src/Yoda/EventBundle/Entity/Event.php. How? It just takes
the full class name, flips the slashes, and adds .php to the end of it:
Now you know all the secrets about the autoloader. And when you see a class
not found error, it's your fault. Sorry! The most common mistake is easily
a missing use statement. If it's not that, check for a typo in your class