Starting with Joomla 4, your component has another
optional[8] part: the api
part. Just like the
component's frontend (site) and backend (administrator) it has its own
Controllers, Views, and Models to render not HTML pages but JSON result
sets.
The namespace suffix for the API application is
Api
. This means that a component with the
namespace prefix Acme\Component\Example
defined
in its XML manifest will have the namespace prefix
Acme\Component\Example\Api
for all of its API
application classes.
If you are implementing an integration with the Joomla API
application your XML manifest needs to have an <api>
section under the <extension>
root node, defining the
files and folders included in your component's api part. Typically, it
looks like this:
<api> <files folder="api"> <folder>src</folder> </files> </api>
Yes, typically you only have one folder,
src
, containing your Controllers, Views and
Models.
[8] A component must have a backend (administrator) part. The frontend (site) and api parts are optional. And, yes, this means that you can absolutely have a backend-only component but not a frontend-only or api-only component. The necessity for a backend part comes from the fact that the XML manifest, the configuration (config.xml) and the permissions (access.xml) files are present only in the backend directory of the component. The former is necessary for a component to be able to be installed, updated and uninstalled. Moreover, Joomla always creates a backend menu item for the component, meaning that the component must have a backend part with a default view even if it's just to display a message that there is nothing to do with this component in the backend.