Bare Minimum¶
This is an example of the minimum layers that should exist.
Define a route (Configuration/Routes.yml)
extension_demo-test: path: api/demo/test controller: Vendor\Demo\Controller\DemoApiController::test defaults: plugin: DemoApi
Register Plugin namespace (ext_localconf.php)
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( 'LMS.demo', 'DemoApi', [ 'DemoApi' => 'test' ], [ 'DemoApi' => 'test' ] );
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 ); } }
Perform a request
curl --location --request GET 'https://demo.ddev.site/api/demo/test'
Response
{ "ok": true }