Question

I use a custom autoloader to load the classes for my web app, but I have just started working on integrating Twig. Twig, however, wants to register its own autoloader, and this is breaking my autoload function. How do I register multiple autoloaders that can run side-by-side?

Était-ce utile?

La solution

Found the issue. Twig registers its autoloader using the spl_autoload_register function. I was defining mine with a function named __autoload, not manually registering it. Both were being registered, but for some reason, my function wasn't getting triggered. I tried manually registering my function via spl_autoload_register, and both autoloaders work fine.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top