The directory structure of a typical Joomla 4 MVC component is as
follows, assuming it's called com_example and has the
namespace prefix \Acme\Component\Example. Directories are
suffixed with /. Please note that capitalisation
matters (directory and file names are case-sensitive).
-
administrator/components/com_example/The component's backend directory-
forms/Optional. List view forms and search tools forms (formerly in models/forms)-
items.xmlAn example form for the Items list view. -
filter_items.xmlAn example search tools form for the Items list view. -
item.xmlAn example form for the Item edit view. -
…
-
-
language/Not required but you should always somehow provide language files with your extension. The language files of your component (typically installed inadministrator/languages/en-GB)-
en-GB/The English (Great Britain) language files. That's the default Joomla language.-
com_example.iniThe main language file for your component's views. Note that there is no longer anen-GB.prefix; it's implied by the directory the language file is in. -
com_example.sys.iniThe language file used by Joomla to display backend menu items, permissions, the component's Options page, core categories used by your component, select menu item types in the menu manager, and render each menu item type's configuration parameters.
-
-
-
layouts/Optional. Any Joomla Layouts you want to ship with your extension for use in its backend. -
services/Required. Here lives the Service Provider of your component.-
provider.phpThe service provider file.
-
-
sql/Optional, unless your extension makes changes to database structure or content.-
updates/Required. Your component's schema (database) files applied on each update.-
mysql/Optional. Indicates updates for sites running on the MySQL database.-
1.0.0-20220815-0000.sqlA database update file. You should name themversion-date-time.sql. The version part is mandatory.
-
-
-
install.mysql.utf8.sqlThe SQL executed on your component's first installation. Update files are not executed in this case. -
uninstall.mysql.utf8.sqlThe SQL executed on your component's uninstallation. Remove any tables or database data you created.
-
-
src/ Required. The root of your extension's PHP files and the root of the PSR-4
\Acme\Component\Example\Administratornamespace prefix.-
Controller/Required. Your component's controllers-
ItemsController.phpAn example controller for a ListView -
ItemController.phpAn example controller for an AdminView -
…
-
-
Dispatcher/Optional. Holds your custom component dispatcher.-
Dispatcher.phpYour custom component dispatcher.
-
-
Extension/Optional. Holds your custom extension class.-
ExampleExtension.phpYour custom extension class.
-
-
Field/Optional. Custom form fields. Use them in your XML forms using the attributeaddfieldprefix="Acme\Component\Example\Administrator\Field". -
Model/Required. Your component's Models.-
ItemsModel.phpAn example model for the Items list view. -
ItemModel.phpAn example model for the Item view. Handles editing and adding records. -
…
-
-
Provider/Optional. Custom service providers.-
RouterFactory.phpExample of a RouterFactory provider, if you need a frontend SEF URL router.
-
-
Router/Optional. The recommended place to put your custom RouterFactory, if you need a frontend SEF URL router. -
Service/Optional. Custom services.-
Html/Optional. Where your custom HTML services (which are made available through Joomla's HTMLHelper) live.-
Example.phpAn example HTML service.
-
-
-
Table/Required. Your Table classes.-
ItemTable.phpAn example table class for the items of this component (which should ideally live in the #__example_items table if you want to follow Joomla best practices).
-
-
View/Required. Your view classes. All subdirectories must be in Uppercasefirst format and match the controller's name before theControllerword.-
Items/The directory for the Items list view.-
HtmlView.phpThe HTML view class for rendering this backend view.
-
-
Item/The directory for the Item add/edit view.-
HtmlView.phpThe HTML view class for rendering this backend view.
-
-
-
-
tmpl/Required. The view templates for your backend views.![[Important]](/media/com_docimport/admonition/important.png)
Important All the sub-directories are in all lowercase. This is VERY important!
Be careful if you are developing on Windows or macOS (which use case-insensitive filesystems). You might accidentally use MixedCase or Uppercasefirst folder names. While this will work fine on Windows and macOS it will fail on the Linux servers most sites run on. That's because Linux primarily uses case-sensitive filesystems.
-
items/-
default.phpThe view template for the Items view.
-
-
item/-
edit.phpThe view template for the Item view.
-
-
-
access.xmlThe component's permissions configuration file -
config.xmlThe component;s Options page form file -
example.xmlThe component's XML manifest
-
-
components/com_example/The component's frontend directory-
forms/Optional. Any forms for frontend views (formerly in models/forms). -
language/Not required but you should always somehow provide language files with your extension. The language files of your component (typically installed inlanguages/en-GB)-
en-GB/The English (Great Britain) language files. That's the default Joomla language.-
com_example.iniThe main language file for your component's frontend views.
-
-
-
layouts/Optional. Any Joomla Layouts you want to ship with your extension for use in its frontend. -
src/ Required. The root of your extension's PHP files and the root of the PSR-4
\Acme\Component\Example\Sitenamespace prefix.-
Controller/Required. Your component's controllers -
Dispatcher/Optional. Holds your custom component dispatcher for the frontend only.-
Dispatcher.phpYour custom component frontend dispatcher.
-
-
Model/Required. Your component's Models.-
ItemsModel.phpAn example model for the Items list view. -
ItemModel.phpAn example model for the Item view. Handles editing and adding records. -
…
-
-
Service/Optional. Custom services.-
Category.phpOptional. Your site's category service. -
Router.phpOptional. Your site's SEF router.
-
-
View/Required. Your frontend view classes. All subdirectories must be in Uppercasefirst format and match the controller's name before theControllerword.
-
-
tmpl/Required. The view templates for your backend views. All the sub-directories are in all lowercase.
-
-
api/components/com_example/Optional. Your Joomla API application integration. Just having this directory is not enough, you will also need a published plugin for your application in thewebservicesfolder.-
src/ Required. The root of your extension's PHP files and the root of the PSR-4
\Acme\Component\Example\Apinamespace prefix.-
Controller/Required. Your component's controllers -
View/Required. Your API view classes. All subdirectories must be in Uppercasefirst format and match the controller's name before theControllerword. Note that these views DO NOT use view template files; they return JSON data directly.
-
-
-
media/com_example/Optional. Your component's static assets.-
css/Optional. Custom CSS files for your component. -
js/Optional. Custom JavaScript files for your component. -
joomla.asset.jsonThe WebAssetManager configuration file for your static assets.
-