Download the PHP package faktore/fe-json-api-utilities without Composer
On this page you can find all versions of the php package faktore/fe-json-api-utilities. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download faktore/fe-json-api-utilities
More information about faktore/fe-json-api-utilities
Files in faktore/fe-json-api-utilities
Package fe-json-api-utilities
Short Description Faktor E JSON Utilities
License GPL-2.0+
Homepage https://www.faktor-e.de/
Informations about the package fe-json-api-utilities
Faktor E JSON API Utilites package
Purpose
This TYPO3 extension helps extension authors with setting up a simple JSON-based API. It provides some helper methods and classes that can:
- parse the JSON request data
- build, enrich and send a JSON response
- transform TYPO3-specific models and object storages into structured arrays
Motivation
Several of our recent projects have demands for widgets and components implemented in a frontend framework such as Vue. To effectively utilize these frontend components, communication with a TYPO3 backend is usually done via JSON requests & responses.
Since these are usually very isolated widgets that don't require a fully fledged (headless) API, extensions like TYPO3 headless or t3api are very impressive, but they would be overkill in our use context. Instead we decided to go with this lightweight, self-maintainable solution.
Usage
JSON Requests
If you want to handle POST data from a request, create a new instance and make sure to use the and methods. Usage is very basic - Example in an Extbase Controller context:
JSON Responses
Responses can be built with the JsonResponseUtility. You can add response data (in array format), keep track of errors and success status, all in this object.
Object & Property conversion utilities
Here is where you have a ConvertUtility class that can do a lot of magic for you.
Flattening FAL objects or FAL Storages
Use .
Note that in addition to the provided properties, every file in the storage will always yield the key 'publicUrl':
New in 1.4.0: Added a third optional parameter to flattenFileStorage. If true, the 'publicUrl' will be made absolute.
Flattening object storages
this will utilize the propertymapper to access gettable properties of an object
Others
There are a few other utility methods for converting your extbase models to arrays. Feel free to explore!
Disclaimer
This utility library is very limited in scope, and it does not provide anything close to a full API for you. Making use of it in a real-world TYPO3 application will still require some work on your processing of requests and responses.
Important: Use at your own risk. There may be bugs. Remember to handle matters of security in your own code.