It is possible to create library package with namespace as below?
namespace Main{
class PrefixFolderLib1{
//functions
}
}
Not sure how the JLoader will understand the namespace.
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It only takes a minute to sign up.
Sign up to join this communitySure. For example, create mylib
folder in /library
, and a file Myclass.php
with the following content:
namespace mylib;
class Myclass
{
}
You can register your namespace with
JLoader::registerNamespace('mylib', JPATH_ROOT . '/libraries');
And access your class with \mylib\Myclass
. Personally, I create a system plugin to do it automatically:
public function onAfterInitialise()
{
JLoader::registerNamespace('mylib', JPATH_ROOT . '/libraries');
}
onAfterInitialise
?
Nov 17, 2015 at 16:25