Jump to content

Autoloader and PSR4


CodingJungle

Recommended Posts

14 hours ago, bfarber said:

Are you having trouble presently with the autoloading?

yes.

composer packages that are psr4, can have a different file path than NS (where IPS's autoloader only takes the first bit of the NS and then uses the rest of the class called to load the file). a psr4 autoloader can rectify this. the one in IPS can not on its own. i would have to alter the file paths to the libs to get them to load properly and it would mean i would have to do this each time i upgraded them. the autoloader also isn't a 100% psr0 compliant either, as i have several psr0 libs i have to alter, giving them a NS, cause IPS autoloader expects at least 2 bits like (\NS\classname) to work properly, this is not the case in a psr0 autoloader. 

Example:

\Zend\Code\Generator\ClassGenerator -> /vendor/zendframework/zend-code/src/Generator/ClassGenerator.php

\Symfony\Component\Finder\Finder -> /vendor/symfony/finder/Finder.php

in its current form, the IPS autoloader with $PSR0Namespace wouldn't be able to resolve this. as for the example where its not PSR0 compliant, i have a lib erusev-parsedown, 

\Parsedown -> /vendor/erusev/parsedown/Parsedown.php

if i try to use it in the $PSR0namespace, like:

\IPS\IPS::$PSR0Namespace['Parsedown'] = MYPATH.'/erusev/parsedown/';

i get an error how its not found, and if i do this:

\IPS\IPS::$PSR0Namespace['Parsedown'] = MYPATH.'/erusev/parsdown/Parsedown';

i get the same eror, cause the autolaoder is expecting something like 

\Erusev\Parsedown

and it to be like this in the namespace var:

\IPS\IPS::$PSR0Namespace['Erusev'] = MYPATH.'/erusev/parsedown/';

This lib can be loaded by the composers autloader without issue, so the problem is the IPS autoloader isn't fully compatible with psr0 either. 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...