I have an old extension that basically does this in LocalSettings.php:
When I convert it to use wfLoadExtension(), the code becomes:
The second line fails with the error:
PHP Fatal error: Uncaught Error: Class 'Foo' not found in <path>/w/LocalSettings.php
It looks like wfLoadExtension('Foo') does not make the class Foo available in time. (The extension.js file point properly to the file containing the Foo class.)
Is there a workaround? The extension must run Foo::DoSomething() in global scope.