J3.x

Understanding the Application classes

From Joomla! Documentation

A Joomla! CMS installation consists of several Applications:

The main applications are Administrator, Site, and Installation. Each application extends the abstract base class \\Joomla\\Application\\AbstractApplication with objects JApplicationAdministrator, JApplicationSite, and InstallationApplicationWeb respectively.

  Joomla Framework Abstract Application
    |
    |
    |---> Base Application (adds some CMS Specific functions)
            |
            |
            |---> Web Application (adds some generic web application functions)
            |       |
            |       |
            |       |---> JApplicationCms (things specific for running the CMS)
            |               |
            |               |---> JApplicationAdministrator
            |               |
            |               |---> JApplicationSite
            |               |
            |               |---> InstallationApplicationWeb
            |
            |
            |---> CLI Application
            |
            |
            |---> Daemon Application

You can always obtain the a reference to the Application object currently being run by simply using the code. $app = JFactory::getApplication(); and it is an object of type JApplicationAdministrator, JApplicationSite or InstallationApplicationWeb depending on the application currently running.

This provides an easy way for extensions to reference global application properties and methods without having to be concerned with which Application object is currently being referenced. When a component is operating in the backend, <source lang="php" inline>JFactory::getApplication() will be pointing to the JApplicationAdministrator object. When a component is operating in the frontend, <source lang="php" inline>JFactory::getApplication() will be pointing to the JApplicationSite Application object.

Command Line Applications

As you can see we've covered the 3 application's that cover all the usage of the website your use in your browser. However Joomla can also cover more than this - it can also deal with CLI Applications. People building their own CLI Applications need to extend the Joomla Abstract CLI Application JApplicationCli that is found in the CMS. You can find examples of these in the CLI directory of your Joomla installation.

People can also run daemon processes in Joomla by using the JApplicationDaemon class.