This is step-by-step actionable guide on how to create a Joomla component from scratch. As an example, we will be creating Joomla component Planets. This component will contain information about the planets.

Step 1: Directory Setup and Manifest Files

The main directory of the component will be com_planet. In this, you need two folders - admin and site. You also need manifest file - planet.xml. Keep changing the manifest file as you develop your extension and add more files and features.

  • admin
  • site
  • planet.xml

Step 2: Language Files

Create language files for both admin and site part.

  • admin/language/en-GB/en-GB.com_planet.ini
  • admin/language/en-GB/en-GB.com_planet.sys.ini
  • site/language/en-GB/en-GB.com_planet.ini

Step 3: Database Design

First, you need to plan what database tables are required for the component. Create install, uninstall and upgrade (upgrade file will be empty at present) SQL files.

  • admin/sql/install.mysql.utf8.sql
  • admin/sql/uninstall.mysql.utf8.sql
  • admin/sql/updates/mysql/0.0.1.sql

Step 4: Basic Back-end: Controllers, Views & Models

The main entry point for Joomla back-end or administrator part is admin/planet.php file.

Create main entry file for the admin part, main controller file (define default view here), and corresponding views and models.

  1. Main Entry File: admin/planet.php
  2. Base Controller: admin/controller.php
  3. Default View: admin/views/planets/view.html.php
  4. Default View Layout File: admin/views/planets/tmpl/default.php
  5. Model for Default View: admin/models/planets.php

How To Create Joomla Component

Step 5: Data For Back-end List View

Get the following in view file (view.html.php) from the corresponding model file (planets.php), and display in the corresponding layout file (default.php)

Add the page title and toolbar to the view file.

Step 6: Back-end Add, Edit Forms and Other Actions: Sub controllers

Back-end Actions, Master Controller and Sub Controllers

Create sub-controller files, corresponding views and models.

  1. admin/controllers/planet.php
  2. admin/controllers/planets.php
  3. admin/views/planet/view.html.php
  4. admin/views/planet/tmpl/edit.php
  5. admin/models/planet.php

Get the following in view file (view.html.php) from the corresponding model file (planet.php), and use in the corresponding layout file (edit.php)

Add the page title and toolbar to the view file.

Step 7: Setup Front-end or Site Part

The file, site/planet.php is the site entry point to the component.

Part A: Basics

Part B: Specifics

Step 8: Using the database

Components usually manage their content using the database.

Step 9: Advanced Component Development

  1. How to Use User State Variables
  2. Link with Joomla Categories Component
  3. Add Configuration Options and Parameters
  4. Access Menu Parameters for Component
  5. Add Alias Field
  6. Create Router for Component
  7. Add Access Control List (ACL) in Joomla
  8. Working with Images in Component
  9. Add Update Server to Component
  10. Link with Joomla Custom Fields