Libraries, Namespaces and Joomla's Autoloader

189 views
Skip to first unread message

MonkeyT

unread,
Feb 22, 2016, 12:05:39 AM2/22/16
to Joomla! General Development
I am attempting to include an existing, namespaced library of PHP code ( PHRETS v2, from https://github.com/troydavisson/PHRETS ).  It appears to have been originally packaged for reuse, and claims all you need for compatibility is to require "vendor/autoload.php", which I redirected to Joomla's Libraries.  I dropped it into a Joomla Library installer which works well, but am having great difficulty getting Joomla's autoloader to recognize it.  

There is very little info out there about how to troubleshoot Joomla's autoloader, and a weekend of experimenting with JLoader::discover, registerNamespaces and registerAlias still leaves me very very confused about what needs to be done.

It appears to also have been written for a system with Guzzle installed for Http connections, so I've made an installer for that library as well.

The normal Joomla debug mechanisms and error reporting don't seem to prove much help for figuring out errors this deep within PHP's operations.

Any guidance for configuring and troubleshooting the autoloader?

Tim

Rob Clayburn

unread,
Feb 25, 2016, 12:03:11 PM2/25/16
to Joomla! General Development
Hi Tim

I wound up making my own library and installing my composer files there:

then in my component I just require the vendor include file.

$loader     = require JPATH_LIBRARIES . '/fabrik/vendor/autoload.php';

(Ignore the include.php file I have there - that's for  custom autoloading of classes)
Reply all
Reply to author
Forward
0 new messages