httpful icon indicating copy to clipboard operation
httpful copied to clipboard

Prepend autoloader on the autoload stack by default

Open matths opened this issue 11 years ago • 1 comments

Hi,

this is just a suggestion, because it took me hours to integrate httpful into an exisiting eCommerce project (using OXID) that comes with its own autoloader added to the autoload stack. My custom module will require the httpful bootstrap after the whole OXID autoloader registration has already happened. So the autoloader from httpful is (for whatever reason) never called, because it's registered after the OXID autoloader (appended).

There's an optional third parameter, which when set to true will force the httpful autoloader to be prepended. I consider that as best practice and more unobtrusive. Maybe I'm wrong. I leave it up to you. ;)

// in vendor/nategood/httpful/src/Httpful/Bootstrap.php spl_autoload_register(array('\Httpful\Bootstrap', 'autoload'), true, **true**);

See PHP Doc: http://php.net/manual/de/function.spl-autoload-register.php

Br, matths

matths avatar Sep 05 '14 07:09 matths

I worry about this having adverse effects on other projects if we say prepend (the same way OXID has adverse effects on Httpful). Part of me wants to say this is an issue with OXIDs auto loader. Could OXID or another piece of your code/libraries perhaps be using __autoload() which would nuke anything with spl_autload_register?

nategood avatar Nov 13 '14 16:11 nategood