Bare Minimum

This is an example of the minimum layers that should exist.

  1. Define a route (Configuration/Routes.yml)

    extension_demo-test:
       path:         api/demo/test
       controller:   Vendor\Demo\Controller\DemoApiController::test
       defaults:
          plugin:    DemoApi
    
  2. Register Plugin namespace (ext_localconf.php)

    \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
        'LMS.demo',
        'DemoApi',
        [
            'DemoApi' => 'test'
        ],
        [
            'DemoApi' => 'test'
        ]
    );
    
  3. Create Controller (Classes/Controller/DemoApiController.php)

    <?php
        declare(strict_types = 1);
    
        namespace LMS\Demo\Controller;
    
        class DemoApiController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
        {
            /**
            * @return string
            */
            public function testAction(): string
            {
                return json_encode(
                    'ok' => true
                );
            }
        }
    
  4. Perform a request

    curl --location --request GET 'https://demo.ddev.site/api/demo/test'
    
  5. Response

    {
        "ok": true
    }