2

I like to develop a fresh Joomla Component for Joomla 3.x in Eclipse and created therefore a simple PHP project.

The problem I have is now how to setup the correct "include path", so that the basic Joomla PHP classes get found by the PHP compiler inside eclipse at coding time like "JFactory" , "JAccess", "JObject" ...

If I just include a Joomla installation in my include path, this will not work. I assume the paths to the classes are more sophisticated than that.

Any Idea or suggestion how the "include path" for my project should look like?

regards Mark

2 Answers 2

1

I'm a little confused by created therefore a simple PHP project so I'll assuming by this you're referring to your component.

Basically, all Joomla clases (Jxxx) are autoloaded (I think with exception of a couple such as JFolder, JFile, and a few others), so you can just access them directly without having to import them:

$user = JFactory::getUser();
$access = JAccess::getGroupsByUser($user->get('id'));
$object = new JObject();

You can of course call the namespaced class names instead, like so:

use Joomla\CMS\Factory;
use Joomla\CMS\Access\Access;
use Joomla\CMS\Object\CMSObject;

class Foo
{
    function test()
    {
        $user = Factory::getUser();
        $access = Access::getGroupsByUser($user->get('id'));
        $object = new CMSObject; 
    }
}
1
  • Thanks but I am referring to the include path of the PHP compiler inside eclipse at development time not at runtime. There will no autoload be used except there is a trick to activate it?
    – megloff
    Mar 22, 2019 at 9:06
0

I have exactly the same problem and have been ignoring it and periodically I see if I can find a way to solve it.

The only workaround I have come up with is to do component development in a project that includes a full Joomla fileset (with all of the bits of my component in the place joomla expects to find them) rather than in the structure that is needed to package up the extension.

There must be a way to simply tell Eclipse that all the references to JFactory, JHtml, JText etc can be found in a different folder not in the main project...

Eclipse seems to be built around the idea of building a project - which it seems makes no sense when developing a Joomla module/plugin/component. I'm puzzled, but I offer this workaround as a kludge solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.