Download the PHP package otlib/rest-api without Composer
On this page you can find all versions of the php package otlib/rest-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package rest-api
Otlib Rest API - TYPO3 REST API Extension
This extension allows you to create and configure RESTful API endpoints in TYPO3 using the Otlib\RestApi\Api
. It provides a
flexible way to define routes, controllers, authentication types, and request methods, enabling developers to build robust APIs
for TYPO3.
Installation
-
Run the following command to install the package via Composer:
- Or download the repository and add it to your extensions. https://github.com/othmanmajd/otlib-rest-api.git
Defining an API Endpoint
Use the Otlib\RestApi\Api class to define your API endpoints. You can set up the path, controller, method, request method, and authentication type.
Basic Usage
The following example demonstrates creating a basic API endpoint that responds to GET requests. This example creates a GET endpoint at that calls the list method of ProductController.
Advanced Usage
The following example demonstrates creating a more advanced API endpoint with custom settings:. This example creates a POST endpoint at check that requires Bearer token authentication and calls the check method of the ProductController.
Authentication Types
The extension supports the following authentication types:
- None: No authentication is required.
- Basic: Basic authentication using a username and password.
- Bearer: Bearer token authentication.
- Frontend TYPO3 User: Authentication using TYPO3 frontend user session (fe_typo_user) or Username and Password.
Setting Authentication
Error Handling
The extension uses custom exceptions to handle errors:
- InvalidRequestMethodException: Thrown when the request method doesn't match the API's configuration.
- MethodNotFoundException: Thrown when the specified controller method doesn't exist.
- ApiPathNotSetException: Thrown when the API path is not set.
JSON Response for Errors
The middleware will return a JsonResponse with appropriate HTTP status codes and messages for errors, such as unauthorized access (401 Unauthorized) or method not found.
Running the Extension
- Define your API endpoints in your TYPO3 extension's setup.
- Make requests to the API using tools like Postman, curl, or custom clients.
- Secure endpoints using the supported authentication types.