Extensions and the manifest file
An extension is a folder with code and an XML description file. This file (the manifest) tells Joomla what kind of extension it is, what it is called and which files belong to it. Without it Joomla does not see the extension.
Types of extensions
| Type | type value | Name | Where it is installed |
|---|---|---|---|
| Component | component | com_hello | components/com_hello and administrator/components/com_hello |
| Module | module | mod_hello | modules/mod_hello |
| Plugin | plugin | plg_content_hello | plugins/content/hello |
| Template | template | mytheme | templates/mytheme |
| Language pack | language | fr-FR | language/fr-FR |
| Package | package | pkg_hello | Several extensions in one archive |
Extension names are written in lowercase Latin letters. The prefixes com_, mod_, plg_ are mandatory: Joomla uses them to find folders and language files.
The manifest file
The manifest sits in the root of the extension. Here is the shortest module manifest — the file modules/mod_hello/mod_hello.xml:
<?xml version="1.0" encoding="UTF-8"?>
<extension type="module" client="site" method="upgrade">
<name>mod_hello</name>
<author>Anna Smith</author>
<version>1.0.0</version>
<description>A greeting module</description>
<namespace path="src">My\Module\Hello</namespace>
<files>
<folder module="mod_hello">services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
</extension>This file outputs nothing yet: it only describes the module that appears in the next lesson.
What the tags mean
| Tag or attribute | Purpose |
|---|---|
type | The type of extension |
client | For the site (site) or for the panel (administrator) |
method="upgrade" | Allows installing a new version over the old one |
name | The system name of the extension |
version | The version number — updates rely on it |
namespace | The namespace of the classes and the folder they live in |
files | Folders and files that belong to the extension |
The manifest file name depends on the type: for a module it matches the module name (mod_hello.xml), for a plugin and a component it is the name without the prefix (hello.xml), for a template it is always templateDetails.xml.
Namespace
In the namespace tag you invent a name once: Vendor\Type\Name. In this course the vendor is My; in a real project use your company name. Joomla maps this name to the src folder and finds classes itself — there is no need to include files with require.
Installing from an archive
The extension folder is packed into a ZIP so that the manifest is in the root of the archive. The archive is uploaded in the panel: System → Install → Extensions, the Upload Package File tab. This is how users install extensions.
Installing through Discover
During development another way is more convenient: put the folder straight into its place, for example modules/mod_hello, open System → Install → Discover and press Discover. Joomla shows the extension it found — tick it and press Install. After that you edit the files in place and see the changes immediately.
The list of everything installed is in System → Manage → Extensions.
Common mistake
The files were copied into the modules folder, but the module is missing in the panel. Copying is not installing: Joomla learns about an extension only from a row in the #__extensions table, which the installer creates. Go through the Discover step and the extension shows up.