Create a component with something like this in the installer script:
JLoader::registerNamespace('Example', JPATH_COMPONENT);
use Example\aClass;
aClass::getInstance();
class Com_ExampleInstallerScript
{
...
}
The aClass
is instantiated.
Fatal error: Class 'Example\aClass' not found in C:\server\www\tmp\install_589ac57e8c134\com_example\installer.php on line 6
Joomla 3.4.3, Win7x64, nginx, php 5.4
It would be nice to load some utility classes for the installer.
Labels |
Added:
?
|
In Joomla, JPATH_COMPONENT always point to the folder of the component being executed which is administrator/components/com_installer in this case
To be safe, you can use JPATH_ROOT . '/components/com_yourcom' or JPATH_ADMINISTRATOR . '/components/com_yourcom' instead of JPATH_COMPONENT
For now, this issue can be closed.
Closing as expected behavior. JPATH_COMPONENT
is a relative constant and should not be relied on as an absolute path declaration.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-02-08 12:54:22 |
Closed_By | ⇒ | mbabker |
It works using the
JLoader::registerNamespace('Example', __DIR__);
. It would be nice to use the sameJPATH_COMPONENT
constant in the installer script, if possible.