Most often WordPress developers uses manual file loading by just typing require_once all the time. But this approach is not good for all cases. There is few moments which you should to know:
— Load each file manually. But what if you have over 400 files or more?
— Your code contains the logic of loading files. And you probably doing more work by designing this logic of loading files.
— Some methods and classes may missed (loaded too later).
— One more node for testing. You need to make sure that your loaders work as intended.
The good news — you can use autoloaders and this is not required something special. And this keynote about autoloaders and Composer.
4. function hello_dolly_get_lyric() {
/** These are the lyrics to Hello Dolly */
$lyrics = "Hello, Dolly
Well, hello, Dolly
It's so nice to have you back where you belong
You're lookin' swell, Dolly
I can tell, Dolly
You're still glowin', you're still crowin'
You're still goin' strong
We feel the room swayin'
While the band's playin'
One of your old favourite songs from way back when
So, take her wrap, fellas
Find her an empty lap, fellas
Dolly'll never go away again
Hello, Dolly
Well, hello, Dolly
It's so nice to have you back where you belong
You're lookin' swell, Dolly
I can tell, Dolly
You're still glowin', you're still crowin'
You're still goin' strong
We feel the room swayin'
While the band's playin'
One of your old favourite songs from way back when
Golly, gee, fellas
Find her a vacant knee, fellas
10. Зачем нужна автозагрузка?
1.Любой код (файл) доступен в любое время.
2.Меньше логики.
3.Универсальность.
4.Совместимость с другими проектами.
5.Меньшая вероятность коллизий.
6.Лучшая структура и красивые имена.