Getting started

What does it do

T3api extension provides easy configurable and customizable REST API for your Extbase models. It allows to configure whole API functionality with annotations for classes, properties and methods.

Most of configuration options is based on API Platform to make it easier to use for developers experienced in this awesome framework.

T3api comes with partial support of JSON-LD and Hydra, which allows to build smart frontend applications with auto-discoverability capabilities.

If you want to fast check working example check demo at: https://github.com/sourcebroker/t3api-demo

@todo - write docs: short description for IRI

Installation

Run composer require sourcebroker/t3api.

Configuration

TYPO3 8.7

Open main Template record and add T3api in tab Includes -> field Include static (from extensions). Note! Not all options are back ported to TYPO3 8.7.

TYPO3 9.5 / 10.4

For TYPO3 9.5 / TYPO3 10.4 import route enhancer by adding following line on bottom of your site config.yaml .

imports:
  - { resource: "EXT:t3api/Configuration/Routing/config.yaml" }

If you do not want to use import you can also manually add new route enhancer of type T3apiResourceEnhancer directly in your site configuration.

routeEnhancers:
  T3api:
    type: T3apiResourceEnhancer

Default base path to api requests is: _api. To change it, it is needed to extend route enhancer configuration by basePath property, as in example below:

routeEnhancers:
  T3api:
    type: T3apiResourceEnhancer
    basePath: 'my_custom_api_basepath'

Creating API resource

Next step is to make an API resource from our entity. To map Extbase model to API resource it is just needed to add @SourceBroker\T3api\Annotation\ApiResource annotation to our model class.

use SourceBroker\T3api\Annotation\ApiResource;

/**
 * @ApiResource()
 */
class Item extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
}

Note

API resource can be created only from class which:

  • Extends \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject.
  • Is kept in path EXT:{extkey}/Classes/Domain/Model.
  • Exists in enabled extension.