[BUG]: "Add API" generates the api folder, but the component manifest has no <api> section, so Joomla never installs the API #1325

Closed
opened 2026-10-16 13:05:20 +00:00 by Markus · 1 comment
Member

What Happened?

When "Add API" is set to List (or Item/Both) for an admin view in the component's Admin Views tab, the compiler correctly creates

api/src/Controller/<Views>Controller.php
api/src/View/<Views>/JsonapiView.php

in the package. However, the generated component manifest (<component>.xml) contains no <api> section. Joomla's installer only copies the API client files that are declared in the manifest, so the api folder is never installed and the endpoints do not exist after installation.

The manifest template administrator/components/com_componentbuilder/compiler/joomla_4/component.xml (which is also used for Joomla 5 and 6 targets) has no <api> block and no placeholder for one. Compiler::cleanupApiFolderIfRequired() only handles the opposite case (it removes the api folder when add_api is null), and nothing adds the manifest section when add_api is 1.

When at least one admin view has an API, the manifest should contain:

<api>
    <files folder="api">
        <filename>index.html</filename>
        <folder>src</folder>
    </files>
</api>

Workaround we use locally

In VDM\Joomla\Componentbuilder\Compiler::cleanupApiFolderIfRequired() we added an elseif ((int) $this->config->get('add_api') === 1) branch that inserts the block above before </extension> (same approach as the existing cleanupSiteFolderIfRequired(), which edits the generated XML). Happy to share the diff.

Related observation (not blocking)

JCB does not generate the webservices plugin that registers the API routes (onBeforeApiRoute). We are building one ourselves as a JCB plugin (group webservices, onBeforeApiRoute), but it might be worth a note in the documentation that "Add API" alone does not make the endpoints reachable.

Steps to reproduce the Bug

  1. Open any Joomla 4/5/6 component in JCB → tab Admin Views.
  2. For one admin view, set the API column to List (same result with Item or Both) and save.
  3. Compile the component.
  4. Unzip the generated package and look at the folders and the manifest:
    • api/src/Controller/<Views>Controller.php and api/src/View/<Views>/JsonapiView.php are present.
    • The component manifest <component>.xml contains no <api> section.
  5. Install the package on a Joomla site.
  6. Check api/components/com_<component>/ on that site: the API files were not copied
    (at most an empty folder is created by Joomla), so the API controller cannot be reached.

Which Joomla version are you compiling in?

6.2.0

Which PHP version are you compiling in?

8.3

Which Joomla versions are you targeting?

6.2 (target: Joomla 6 component)

Which PHP version are you targeting?

8.3 / 8.5

Which Web server is JCB running on?

Apache/2.4.67 (Debian)

Which Relational Database is JCB running on?

10.5.29-MariaDB-0+deb11u1 Debian 11

Which OS is JCB running on?

Debian 11

Which JCB version are you using?

6.1.6

Where in JCB did this issue occur?

Other

On which browsers did you encounter the issue?

Firefox

Additional Comments

No response

### What Happened? When "Add API" is set to *List* (or *Item*/*Both*) for an admin view in the component's Admin Views tab, the compiler correctly creates ``` api/src/Controller/<Views>Controller.php api/src/View/<Views>/JsonapiView.php ``` in the package. However, the generated component manifest (`<component>.xml`) contains no `<api>` section. Joomla's installer only copies the API client files that are declared in the manifest, so the `api` folder is never installed and the endpoints do not exist after installation. The manifest template `administrator/components/com_componentbuilder/compiler/joomla_4/component.xml` (which is also used for Joomla 5 and 6 targets) has no `<api>` block and no placeholder for one. `Compiler::cleanupApiFolderIfRequired()` only handles the opposite case (it removes the `api` folder when `add_api` is `null`), and nothing adds the manifest section when `add_api` is `1`. When at least one admin view has an API, the manifest should contain: ```xml <api> <files folder="api"> <filename>index.html</filename> <folder>src</folder> </files> </api> ``` Workaround we use locally In `VDM\Joomla\Componentbuilder\Compiler::cleanupApiFolderIfRequired()` we added an `elseif ((int) $this->config->get('add_api') === 1)` branch that inserts the block above before `</extension>` (same approach as the existing `cleanupSiteFolderIfRequired()`, which edits the generated XML). Happy to share the diff. Related observation (not blocking) JCB does not generate the `webservices` plugin that registers the API routes (`onBeforeApiRoute`). We are building one ourselves as a JCB plugin (group `webservices`, `onBeforeApiRoute`), but it might be worth a note in the documentation that "Add API" alone does not make the endpoints reachable. ### Steps to reproduce the Bug 1. Open any Joomla 4/5/6 component in JCB → tab **Admin Views**. 2. For one admin view, set the **API** column to **List** (same result with *Item* or *Both*) and save. 3. Compile the component. 4. Unzip the generated package and look at the folders and the manifest: - `api/src/Controller/<Views>Controller.php` and `api/src/View/<Views>/JsonapiView.php` **are** present. - The component manifest `<component>.xml` contains **no** `<api>` section. 5. Install the package on a Joomla site. 6. Check `api/components/com_<component>/` on that site: the API files were **not** copied (at most an empty folder is created by Joomla), so the API controller cannot be reached. ### Which Joomla version are you compiling in? 6.2.0 ### Which PHP version are you compiling in? 8.3 ### Which Joomla versions are you targeting? 6.2 (target: Joomla 6 component) ### Which PHP version are you targeting? 8.3 / 8.5 ### Which Web server is JCB running on? Apache/2.4.67 (Debian) ### Which Relational Database is JCB running on? 10.5.29-MariaDB-0+deb11u1 Debian 11 ### Which OS is JCB running on? Debian 11 ### Which JCB version are you using? 6.1.6 ### Where in JCB did this issue occur? Other ### On which browsers did you encounter the issue? Firefox ### Additional Comments _No response_
Markus added the Bug label 2026-10-16 13:05:21 +00:00
Author
Member

I see, this issue has been fixed in 6.2 - should have tried this before. sorry for the inconvenience...

I see, this issue has been fixed in 6.2 - should have tried this before. sorry for the inconvenience...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1325