JLoader::registerNamespace('MyNamespace', '/path/to/my/namespace'); $myclass = new MyNamespace\MyClass();
JLoader::registerPrefix('JController', '/path/to/joomla'); $jcontroller = new JController();This code registers the prefix "JController" with the directory path "/path/to/joomla", and then creates a new instance of the class "JController" which is part of the "joomla.application.component.controller" package. In both examples, JLoader is used to register a namespace or prefix with a directory path and then to instantiate a class or use a library package. The package library for these examples is the Joomla platform, but JLoader can be used with any package library.