Skip to content

Examples

Alexander Saal edited this page Aug 7, 2025 · 2 revisions

Examples

Example Use Case: Displaying User Information

To help you get started with real-world development using the SDK, this chapter presents a simple but common scenario: displaying information about the currently logged-in user.

This example illustrates how you can implement the same functionality in different ways, depending on your preferred workflow, toolchain, or frontend requirements.

We’ll demonstrate three typical approaches:

  1. Raw HTML with PHP: Output is directly generated in PHP.
  2. Twig Template Rendering: A cleaner separation of logic and presentation using the Twig templating engine.
  3. JSON Output: Returning structured user data as JSON, suitable for frontend frameworks or AJAX-based components.

Each version uses the same SDK interface to access user information, but handles the output differently.

Note

You can use these examples as starting points and adapt them to your own application structure or frontend stack.

When to Use Which Approach?

Each rendering method serves a different use case. Here’s a quick guide to help you choose the right one for your custom application:

Ideal for quick prototypes, admin tools, or simple outputs that don’t require much structure.

  • ✅ Fast and straightforward
  • ❌ Becomes harder to maintain with growing complexity

Best suited for applications with a UI that needs to be cleanly separated from business logic.

  • ✅ Easier to read and maintain
  • ✅ Great for multi-language support and reusable templates
  • ❌ Requires including and configuring Twig (if not already part of your project)

Useful when building dynamic frontends (e.g. with JavaScript or React) or providing API-like endpoints.

  • ✅ Ideal for asynchronous requests and modern UIs
  • ✅ Can be reused by multiple clients (e.g. internal tools, dashboards)
  • ❌ Not directly human-readable in the browser

Clone this wiki locally