?
avatar inf3rno
inf3rno
8 Feb 2017

Steps to reproduce the issue

Create a component with something like this in the installer script:

JLoader::registerNamespace('Example', JPATH_COMPONENT);

use Example\aClass;

aClass::getInstance();

class Com_ExampleInstallerScript
{
	...
}

Expected result

The aClass is instantiated.

Actual result

Fatal error: Class 'Example\aClass' not found in C:\server\www\tmp\install_589ac57e8c134\com_example\installer.php on line 6

System information (as much as possible)

Joomla 3.4.3, Win7x64, nginx, php 5.4

Additional comments

It would be nice to load some utility classes for the installer.

avatar inf3rno inf3rno - open - 8 Feb 2017
avatar joomla-cms-bot joomla-cms-bot - change - 8 Feb 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 8 Feb 2017
avatar inf3rno
inf3rno - comment - 8 Feb 2017

It works using the JLoader::registerNamespace('Example', __DIR__);. It would be nice to use the same JPATH_COMPONENT constant in the installer script, if possible.

avatar joomdonation
joomdonation - comment - 8 Feb 2017

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.

avatar mbabker
mbabker - comment - 8 Feb 2017

Closing as expected behavior. JPATH_COMPONENT is a relative constant and should not be relied on as an absolute path declaration.

avatar mbabker mbabker - change - 8 Feb 2017
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-02-08 12:54:22
Closed_By mbabker
avatar mbabker mbabker - close - 8 Feb 2017

Add a Comment

Login with GitHub to post a comment