Every developer uses a set of tools that simplifies their life and without which their development life feels crippled! Over the years, I have developed my own set of tools which I have described in this blog.

The primary OS for my development related tasks is Ubuntu with Eclipse IDE, so the entire blog is targeted for Eclipse.

When I was a newbie in the industry, I only knew basic PHP. Setting up a development machine was as easy as installing PHP, MySQL and installing Joomla CMS.

But as time passed by, I learned some new things, tricks which I'm going to share with you. Obviously this is a continuous process as you will always learn new things being a part of the software industry- so thinking that by next year I would have learned a few more tips and tricks has already brought a smile on my face.

Eclipse IDE

The IDE plays the most important role in a developer’s life. The right choice of an IDE can save you plenty of time. 

In today's market, we can see lots of IDE’s are available and by the market share almost 40% of the market is owned by the VS code. I personally prefer the Eclipse IDE with PDT. Obviously every IDE has some pros and cons and as far as Eclipse is concerned I can see the following advantages.

  1. Open-source
  2. Content assistance
  3. Eclipse Marketplace
  4. Multiple project support

How to install Eclipse IDE

You can find the instructions on how to install Eclipse on the official documentation site by referring this link

In addition, you can also refer the following link-

Here is the Official document link on how to setup Eclipse for Joomla which is outdated but may help to understand a few things.

Configuring Eclipse

Setup code formatter

Everyone loves to see code which is well-formatted. Eclipse comes with predefined format rule sets which can be edited to comply with Joomla’s PHPCS standards. 

I have created the Joomla ruleset which covers 90% of the Joomla PHPCS standards.

You can download the Joomla.xml file from this link and import it to the formatter.

Once you download the file Import this into the following location

 Window > Preferences > PHP > Code Style > Formatter

Once the formatter is in place you can format PHP file using the shortcut key

Ctrl + shift + F

Improve the code assistant

While Eclipse comes with out of the box content assistant feature, somehow it has failed to index Joomla classes because Joomla is currently converting it’s classes to namespaces and the process will be completed with the release of Joomla 4. To use namespaces with the old class names, Joomla uses the Classmap function.

To overcome this problem you can generate the stubs.php file which is basically a mapping of the legacy classes to the namespaces. To generate a stubs file you need to run the stub generator file which is under the Joomla's build folder. Refer to this GitHub link.

I have created a stubs file for the 3.9.13 version. You can download this file and store it into the root directory of the project. Refer to this GitHub link.

Once the stubs file is generated you can view the class details by hovering on the class names and navigate to the definition of the class/function by pressing F3 or by ctrl + left click.

The Eclipse IDE will add strikethrough for deprecated classes/methods so you can easily find out such occurrences and replace them with the correct ones.

Type Hinting of dynamically created objects

In Joomla, you can create a different class object by invoking the same method. For example, you can create a user model object inside the model controller by using the following syntax.

 $model = $this->getModel('User', '', array());

By using the same method you can create users' model objects in the users' controller. Now, this creates a problem for Eclipse and it is not able to assist you with the methods provided by the User model.

In this case, you can define the Class name for the variable by using the following syntax

     /** @var $model UsersModelUser */

    $model = $this->getModel('User', 'UsersModel'); 

This is applied to all the dynamic variables in any file.

Shortcut keys

Life becomes easy as pie when you have great shortcuts that perform complicated tasks in a single click. Fortunately, Eclipse provides a wide range of shortcut keys. Here are some of the most commonly used shortcut keys.

  1. Ctrl + Shift + T for finding a class from project
  2. Ctrl + Shift + o for organize imports
  3. Ctrl + / for commenting, uncommenting lines and blocks
  4. Ctrl + l go to line
  5. Ctrl + Shift + F for formatting.

You can find out the whole set of shortcut keys by pressing Ctrl + Shift + L

Hope this will help you to improve your coding skills and improve your productivity at your workplace.

Do you use something cool that I have missed? Do let us know your thoughts in the comments section below.