> For the complete documentation index, see [llms.txt](https://quantumphp.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://quantumphp.gitbook.io/docs/packages/renderer/overview.md).

# Overview

The Renderer package turns a view name plus data into an HTML string.

Use it when your controller, service, or response layer needs to render templates from either the current module or the shared `views` directory.

## What the package provides

The package is built from three small parts:

* `Quantum\Renderer\Factories\RendererFactory` resolves a renderer by adapter name
* `Quantum\Renderer\Renderer` is the wrapper you call from application code
* adapters implement `Quantum\Renderer\Contracts\TemplateRendererInterface`

Built-in adapter names:

* `html`
* `twig`

## How view lookup works

Both built-in adapters use the same lookup order for a view such as `posts/index`:

1. `modules/<CurrentModule>/Views/posts/index.php`
2. `shared/views/posts/index.php`

The current module comes from the active request.

That means module views override shared views automatically when both files exist.

## Default adapter behavior

If you do not request an adapter explicitly, the factory reads `view.default` from the framework view config.

The package imports that config lazily on first use, so most applications can start rendering without a manual setup step as long as `config/view.php` contains a valid default.

## Basic example

```php
use Quantum\Renderer\Factories\RendererFactory;

$renderer = RendererFactory::get();

$html = $renderer->render('posts/index', [
    'posts' => $posts,
    'title' => 'Latest posts',
]);
```

`render()` always returns a string.

## Important constraints

* View names are resolved to `.php` files for both built-in adapters.
* Unsupported adapter names fail immediately with a renderer exception.
* Missing view files fail immediately with a renderer exception.
* Renderer instances are cached per adapter name inside the factory service, so repeated `RendererFactory::get('twig')` calls reuse the same wrapper instance.
* The `html` adapter does not apply adapter config options during rendering.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://quantumphp.gitbook.io/docs/packages/renderer/overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
