Skip to content
Tutorials Center
My learning

Topics

Lesson 2 of 37 ยท Getting Started

How Joomla Works Inside

Follow one request through Joomla: the front controller, router, component, MVC split, template and plugin events, with a runnable mini front controller.

To use Joomla well you should know what happens between a visitor typing a URL and the finished page appearing. You do not need to read the source code, but a mental model helps with every later topic: why a menu item controls a page, why a module needs a position, and why a plugin can change an article without touching it.

This lesson walks through one request, introduces the Model-View-Controller (MVC) pattern that Joomla components use, and explains plugin events. The runnable example is a stand-in: a tiny front controller written in JavaScript that mimics the steps. It is not Joomla's real code, which is PHP.

The front controller

Every page request on a Joomla site goes through one file: index.php in the site root. This is called the front controller pattern. The web server sends all requests that do not match a real file (a CSS file, an image) to index.php, and Joomla decides what to do. The administrator has its own entry point at administrator/index.php, and the web services API uses api/index.php.

Here is the journey of a typical frontend request:

flowchart TD
    A["Browser requests /news/launch"] --> B["index.php boots the application"]
    B --> C["Router parses the URL<br/>finds the menu item 'news'"]
    C --> D["Menu item says: component com_content,<br/>view: category blog"]
    D --> E["Component dispatcher<br/>picks controller, model, view"]
    E --> F["Model loads data from the database"]
    F --> G["View + layout produce HTML"]
    G --> H["Template wraps it and renders modules"]
    H --> I["Response sent to browser"]

A frontend request from URL to HTML.

  1. Boot. Joomla reads configuration.php, connects to the database and starts the session.
  2. Routing. The router turns the URL into parameters such as option=com_content&view=article&id=7. It uses the menu items you created to understand the URL.
  3. Dispatch. The component named in option gets the request.
  4. Render. The component builds its output; the template places it in the page together with modules.
  5. Respond. Joomla sends the HTML.

MVC inside a component

A component is built from three roles that keep the code tidy.

Model, View, Controller

Model Reads and writes the data
View Prepares data for display
Controller Handles the request, calls the others

Layouts are the HTML files a view loads

1 / 2
  • The controller receives the request, checks permissions and decides what happens next.
  • The model talks to the database. Models know nothing about HTML.
  • The view gets data from the model and passes it to a layout, a small PHP file with HTML that produces the output.

For an article page this means: the controller notices that a single article is wanted, the model fetches the row, the view hands it to the default layout, and the layout prints the title and text. Because layouts are separate files, a template can override them without changing the component. You will do that in the templates chapter.

Plugins and events

While all this happens, Joomla keeps announcing events: "content is about to be prepared", "a user logged in", "the page is about to be rendered". Plugins subscribe to events and run code when they fire. That is how a plugin can add a social-sharing bar after every article, or block a login, without any change to the article component.

Plugins are grouped by purpose (for example content, system, user, authentication, editors, captcha), and the group tells you when they load. You enable or disable them in the backend under System > Manage > Plugins.

A mini front controller you can run

The stand-in below has a route table (from menu items), a controller that picks a handler, a model with fake data, a view that renders HTML, and a plugin that listens for an event. Read the code first and then run it.

JS Stand-in: a front controller in miniature

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Notice three things. The front controller never contains article logic; it only maps a URL to a menu item. The controller never writes HTML; the view does. And the plugin appended the copyright text without the model, view or controller knowing about it: that is the event system at work.

JS Stand-in: add your own plugin

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Change the order of the three on lines and see how the result changes. Real Joomla plugins also run in a defined order, which you can influence in the plugin manager.

Why this matters for you

  • A 404 or blank page often means the router found no menu item or the component returned nothing.
  • Overrides work because views and layouts are separate small files.
  • Performance problems usually come from many modules, heavy plugins or slow queries in the model layer.
  • Security updates matter because every request passes through the same core code.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which file receives every normal frontend request?

    index.php is the front controller. It boots Joomla, routes the URL and renders the page.
  2. 2. In MVC, which part talks to the database?

    Models read and write data. Views and layouts only prepare and print it.
  3. 3. How can a plugin change an article without editing the article component?

    Joomla triggers events at key moments. Plugins listen to them and can change the data passed along.
  4. 4. What does the router use to understand a frontend URL?

    Menu items map URL paths to a component and view, so routing starts from them.

Summary

  • All requests pass through the front controller index.php, which boots Joomla and routes the URL.
  • The router relies on menu items to decide which component and view to use.
  • Components follow MVC: controller handles the request, model handles data, view and layout produce HTML.
  • The template places the component output and modules into the page.
  • Plugins subscribe to events and extend behavior without changing core or components.

Next: Joomla Compared with WordPress and Drupal