EXT: Restler 

Classification

Documentation

Version

main

Language

en

Description

This is a TYPO3 Extension, which integrates the Luracast Restler Web API Framework (PHP REST-framework to create REST-API's, https://github.com/Luracast/Restler) in TYPO3.

This extension is based on Luracast Restler Version 3.0.

Keywords

restler, REST, API, RESTful

Copyright

2015 - 2026

Author

AOE GmbH

Email

dev@aoe.com

License

Copyright 2015 - 2026 AOE GmbH

All rights reserved

This Extension is part of the TYPO3 project. The TYPO3 project is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html.

This Extension is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Luracast Restler Version 3.0. is distributed under GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 (see /vendor/luracast/restler/LICENSE) and is included for your convenience in the vendor folder.

Rendered

Tue, 31 Mar 2026 09:10:07 +0000

The content of this document is related to TYPO3, a GNU/GPL CMS/Framework available from www.typo3.org.

Table of Contents

What does it do? 

The target audience is developers looking to expose a REST API from their respective extensions.

This extension gives the possibility of using Luracast Restler in TYPO3. It provides the basis for using REST in your own extensions acting like a wrapper.

You can configure endpoints to be available via normal HTTP methods or using internal REST-like PHP calls.

Contribute back! 

If you find any mistakes in the documentation or our code, we would be honoured if you could submit an issue or a pull request on Github in order to correct it.

Installation Guide 

Describes how to manage the extension from a developer’s point of view.

Target group: Developers

Installation 

  1. Install the extension from TER (sources are available on our GitHub repository).

In the context of a fully Composer setup, add in your root composer.json the following line before doing a `composer update`.

"require": {
    ...
    "aoe/restler": "2.*"
},
Copied!

Because we are using a forked version of Restler (in order to be able to tag a stable version), you also need to add the following to your composer.json file.

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/AOEpeople/Restler.git"
    }
],
Copied!
  1. Configure this TYPO3-Extension (in TYPO3 Extension-Manager; e.g. enable the online documentation of your REST-API). See the "Screenshots" section as well.
  2. (Optional, but recommended) Install the TYPO3 Extension "TYPO3 Restler Examples".
  3. Make the .htaccess changes described below:

The ".htaccess" file needs to be changed in order to make the REST API available.

# The api_explorer/.* MUST not hit TYPO3 (index.php) otherwise the requests will fail.
# This / (target) is only to prevent this to happen.
RewriteRule ^api_explorer/.*$ / [NC,QSA,L]
Copied!

For Nginx use following rule

location ~^/api_explorer/ {
        rewrite ^/api_explorer/(.*)$ / last;
}
Copied!

When this is done, than you can call the online documentation of your REST API via this URL:

www.example.com/api_explorer/

You also can call your REST API via this URL:

www.example.com/api/path-to-my-rest-api-endpoints/ .

Developer Manual 

Describes how to manage the extension from a developer’s point of view.

Target group: Developers

Using TYPO3 Restler in our own extension (aka Exposing your own REST API) 

In order to offer a seamless integration of Restler [#f1] in TYPO3, this extension offers the interface "AoeRestlerSystemRestlerConfigurationInterface".

With classes implementing the "ConfigurationInterface", it is possible to configure Restler:

  • Restler configuration can be defined (eg. supported response format)
  • API endpoints can be defined
  • Authentication classes can be defined (to protect API endpoints against unauthorized access)

Steps:

  1. Create new PHP-class, which implements this Interface:
Aoe\Restler\System\Restler\ConfigurationInterface
Copied!

You can use this PHP-class as example

Aoe\RestlerExamples\System\Restler\Configuration
Copied!

Inside your PHP-class, you can configure the Restler framework:

  • add API classes to the Restler object
  • add Authentication classes to Restler object
  • configure all static properties of PHP classes, which belong to the Restler framework
  1. Register your PHP-class in your TYPO3-Extension (in ext_localconf.php-File)

Any class that implements the "AoeRestlerSystemRestlerConfigurationInterface" interface, must be declared in your extension "ext_localconf.php" file.

// Add the configuration class (in Extension 'restler'):
// In that configuration class, we can:
// - configure the cache directory
// - enable the extbase DI container
// - enable the online API documentation (if enabled in extension-configuration)
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['restler']['restlerConfigurationClasses'][] = 'Aoe\\Restler\\System\\RestlerConfiguration';
Copied!

This way the following will be achieved:

  • each extension can define any number of Restler configuration classes.
  • the Restler configuration classes will only be called when an API endpoint is called (has no side-effects on normal calls of TYPO3).
  1. Flush the TYPO3 System Cache

Using TYPO3 Restler from PHP libraries 

If you like to register API classes to the Restler object that are located outside of TYPO3 use the alternative GLOBAL array to set your configuration class which implements the "AoeRestlerSystemRestlerConfigurationInterface" interface:

// register API-Controller to TYPO3_Restler
$GLOBALS['TYPO3_Restler']['restlerConfigurationClasses'][] =
    yourNamespace\Configuration::class;
Copied!

or you can directly register your REST-controller to an endpoint by using the GLOBAL array:

// register API-Controller to Restler
$GLOBALS['TYPO3_Restler']['addApiClass']['<YOUR_ENDPOINT_PATH>'][] =
    yourNamespace\yourRestController::class;
Copied!

You just have to make sure that this setting is loaded by auto-loading. For example (via composer);

"autoload": {
    "files": [
        "fileWithGlobalConfigurationRegistration.php"
    ]
}
Copied!

Caching of REST-endpoints - via TYPO3-Caching-Framework (experimental) 

Notice: Please note that this feature is experimental and could be removed in further releases.

When you want to use the TYPO3-Caching-Framework to cache the response of your REST-endpoints, you just need to add this two phpdoc-annotations in your REST-endpoint:

Example:

/**
 * The response of this REST-endpoint will be cached by TYPO3-caching-framework, because:
 *  - it's a GET-request/method
 *  - annotation 'restler_typo3cache_expires' (define seconds, after cache is expired; '0' means cache will never expire) is set
 *  - annotation 'restler_typo3cache_tags' (comma-separated list of cache-tags) is set
 *
 * The cache is stored in this TYPO3-tables:
 *  - cache_restler
 *  - cache_restler_tags
 *
 * @url GET my-rest-endpoint-which-should-be-cached
 *
 * @restler_typo3cache_expires 180
 * @restler_typo3cache_tags typo3cache_examples,typo3cache_example_car
 */
public function myRestEndpointWhichShouldBeCached() {

}
Copied!

For details examples please refer to the restler_examples extension.

Exposing Internal APIs (experimental) 

Notice: Please note that this feature is experimental and could be removed in further releases. You can anytime make internal calls by using an HTTP client (for example Guzzle).

Just as you make HTTP calls to your public endpoints, it is possible to declare internal endpoints which you can use in a similar way, but using PHP.

You can practically decouple various components by exposing an internal API which is accessible via HTTP just during development.

Example:

$this->restApiClient->executeRequest('GET', '/api/rest-api-client/internal_endpoint/cars/1')
Copied!

For details examples please refer to the restler_examples extension.

Examples 

To reduce the quantity of documentation required to use Restler, we provide also an example extension called Restler_examples available on TER. You can check first there how the endpoints work.

Also please refer to existing documentation regarding the Restler homepage [#f1].

Footnotes

Configuration Options 

Target group: Developers

You can make various configurations directly from the Extension Manager in TYPO3.

ProductionContext [basic.productionContext] 

When productionContext is not set, than Restler will: - show debug information - not cache the routes (will parse the API-classes every time to map it to the URL)

Refresh cache [basic.refreshCache] 

You can use this configuration to rebuild cache every time in production mode. When in production mode, a cache file for the routes will be written in the cache directory by default.

Enable online documentation [basic.enableOnlineDocumentation] 

Defines whether to enable the online documentation of the REST-API.

Path to online documentation [basic.pathToOnlineDocumentation] 

Defines the path to the online documentation of the REST-API (e.g. www.example.com/<pathToOnlineDocumentation>/)

Screenshots 

Extension configuration:

Restler Configuration Example

API Explorer:

API Explorer

The AOE Way 

AOE ( www.aoe.com ) is a leading provider of Enterprise Open Source web solutions.
Using current agile development methods, more than 180 developers and consultants in 8 global locations
develop customized Open Source solutions for global Fortune 500 companies and corporations.

For more than 15 years we have been designing and developing complex Enterprise Web Content Management
Systems, E-Commerce and Mobile Applications as well as Web Portal solutions based on Open Source
technology and successfully launched over 1,400 projects worldwide.

The integration of Open Source software is a central element of our
corporate philosophy and key driver of our growth.

The sourcecode of this Extension is continuously monitored by a GitHub Action .
Checking for checkstyles, mess detecting, duplicate code and more.