When you type a URL that points to an article in the front page of Joomla site, the first thing that happens depends on the web server (Apache or IIS), not Joomla. The web server first tries to find a file or folder. Failing that, it tries to find a file called index.php. Since this file exists, it is executed. All URLs for the front end start the same way. Every front-end command cycle starts with the web server loading the index.php file.
The Joomla index.php File
The first line of index.php defines a constant _JEXEC.
Next, the index.php file includes a file, defines.php that has a number of constants.
require_once JPATH_BASE . '/includes/defines.php';
After that, it loads the Joomla framework.
require_once JPATH_BASE . '/includes/framework.php';
The framework.php file does some important tasks. It loads the file libraries/cms.php, which in turn loads some important classes, including JFactory. It makes sure you have a configuration.php file. If you don’t have one, it forces to the installation application to try to install Joomla. If the installation files cannot be found, it shows an error message and quits.
Next, the index.php file creates the application object ($app) and then execute it through execute() method.
// Instantiate the application.
$app = JFactory::getApplication('site');
// Execute the application.
At this point, you get a session. Joomla either loads the existing session or create a new one if one isn’t found. Joomla also loads the configuration.php file, which gives access to the Joomla database and other settings for this specific website.
Components in Joomla
When you open any web page powered by Joomla CMS, it delivers the results of a component.
The Joomla tries to find and load the base file from components/com_<name> folder. For example, if your component is 'com_test' you should have a 'com_test' folder and a file named 'test.php' inside of it. Which component get loaded? This depends on the menu item. The default menu item loads the home page of the website.
The base file of the component use a Model-View-Controller (MVC) pattern.
Joomla makes extensive use of the MVC design pattern. When Joomla is started to process a request from a user (browser or client), one of the first things that Joomla does is to analyse the URL to determine which component will be responsible for processing the request, and hand control over to that component. If the component has been designed according to the MVC pattern, it will pass control to the controller. The controller is responsible for analyzing the request and determining which models will be needed to satisfy the request, and which view should be used to return the results back to the user.
The model encapsulates the data (usually from database) used by the component. The model is also responsible for updating the database where appropriate. The purpose of the model is to isolate the controller and view from the details of how data is obtained or amended.
The view is responsible for generating the output that gets sent to the browser by the component. It calls on the model for any information it needs and formats it appropriately.
Modules & Templates in Joomla
As Joomla is designed to be highly modular, the output from the component is generally only part of the complete web page that the user will ultimately see. Once the view has generated the output, the component hands control back to the Joomla framework which then loads and executes the template. The template combines the output from the component, and any modules that are active on the current page, so that it can be delivered to the browser as a single page.
Joomla splits the traditional view into a separate view and layout. The view pulls data from the model and simply makes that data available to the layout, which is responsible for formatting the data for presentation to the user.
The advantage of having this split is that the Joomla template system provides a simple mechanism for layouts to be overridden in the template. These layout overrides or template overrides are bundled with the template and give the template designer complete control over all the output from the Joomla core and any installed third-party extensions that comply with the MVC design pattern.