> 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/asset/helpers.md).

# Helpers

The package exposes two global helpers for common view-layer work.

## `asset()`

```php
$manager = asset();
```

Returns the shared `Quantum\Asset\AssetManager` instance.

Use it to:

* register assets
* look up named assets
* resolve URLs
* clear the registry with `flush()`

Because the manager is shared through DI, repeated calls return the same instance during the current process.

## `assets(string $type)`

```php
assets('css');
assets('js');
```

Renders all registered assets for the requested type.

Use `css` for stylesheet tags and `js` for script tags.

This helper echoes markup directly, so call it from a template, layout, or another output-producing layer.

## Practical pattern

A common pattern is to register assets during request handling and render them once in the base layout.

```php
// controller or middleware
asset()->registerAsset(new Asset(Asset::CSS, 'css/dashboard.css', 'dashboard'));

// layout
<?php assets('css'); ?>
```

That keeps asset decisions close to the feature that needs them without hardcoding every tag in the layout.


---

# 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/asset/helpers.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.
