---
title: "Resources API"
manual: "TYPO3 Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3coreapi:resources@main"
source: "ApiOverview/Resources/Index.rst"
rendered: "2026-09-24T12:36:55+00:00"
---

# Resources API {#resources}

TYPO3 projects and extensions can reference two types of resource files:

Public resources that should be accessible with a browser, such as CSS and JavaScript
files, images and downloads.

Private resources that are used by server-side code, such as templates,
configuration files and localization files.

**Table of contents**

-   [Location for resources in Composer-mode installations](https://docs.typo3.org/permalink/t3coreapi:location-for-resources-in-composer-mode-installations@main)
-   [Resources in classic mode installations](https://docs.typo3.org/permalink/t3coreapi:resources-in-classic-mode-installations@main)
-   [Referencing private resources on the server side](https://docs.typo3.org/permalink/t3coreapi:referencing-private-resources-on-the-server-side@main)
-   [Referencing public resources](https://docs.typo3.org/permalink/t3coreapi:referencing-public-resources@main)

## Location for resources in Composer-mode installations {#resources-composer}

By default, public resources must be put into the folder
`Resources/Public` of an extension or somewhere within the web root
folder in Composer-based installations. Private resources should reside in
folder `Resources/Private` or `Configuration` of an
extension or the folders `config/sites` or `config/system`.

Images and downloads may reside in folder `public/fileadmin` or custom
file storage.

## Resources in classic mode installations {#resources-classic}

In TYPO3 classic mode, all files in extensions are already
located within the document root. Restricting resources to default
locations in classic mode therefore mainly follows coding guidelines
and keeps compatibility with Composer mode.

Classic mode installations should use server side access restriction, for
example by using `.htaccess` or Nginx configurations. `.htaccess` can
be automatically tested and adjusted:
[Verify webserver configuration (.htaccess)](https://docs.typo3.org/permalink/t3coreapi:maintain-htaccess@main).

## Referencing private resources on the server side {#resources-server-side}

The actual directory location where a file can be found varies from installation
to installation. It depends on the mode (Composer / Classic) and on certain
configuration, for example of the `vendor` folder. You should therefore avoid
using absolute or large relative paths like `../../../../public/_assets/12345`.

### The `EXT:` syntax: referencing resources in extensions {#resources-server-side-ext}

Most API functions in PHP and TypoScript expect files to reside in extensions
and accept a syntax such as `EXT:my_extension/Resources/Private/Page/Default.html`.

They resolve the path internally. `my_extension` is the extension key as defined in
[extra.typo3/cms.extension-key](https://docs.typo3.org/permalink/t3coreapi:ext-composer-json-property-extension-key@main)
in the extension's `composer.json`, the rest is the relative path from that
extension's root folder.

### Using API functionality to determine the path to a resource {#resources-server-side-api}

In some rare cases you may need the absolute or relative path to a resource
from within your code.

`\TYPO3\CMS\Core\Utility\GeneralUtility` offers utility method
`GeneralUtility::getFileAbsFileName()` to resolve file paths:

**packages/my_extension/Classes/Something/MyClass.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Something;

use TYPO3\CMS\Core\Utility\GeneralUtility;

class MyClass
{
  public function myFunction(): void
  {
    $absoluteFilePath = GeneralUtility::getFileAbsFileName(
      'EXT:my_extension/Resources/Private/SomeFile.xml',
    );
  }
}

```

The [Environment PHP API](https://docs.typo3.org/permalink/t3coreapi:environment-php-api@main)
can be used to resolve paths to other locations within the project such as the
path to the `config` folder.

## Referencing public resources {#resources-public}

Public resources such as JavaScript and CSS files are usually referenced using
the [Asset collector](https://docs.typo3.org/permalink/t3coreapi:asset-collector@main)
or [f.assets.\* ViewHelpers](https://docs.typo3.org/permalink/t3coreapi:assets-viewhelper@main).

Public resources should not be referenced by their path in the `_assets`
folder as these paths contain a hash that might change during updates.

### Fluid ViewHelper f:uri.resource {#resources-public-viewhelper}

In Fluid you can use the [Uri.resource ViewHelper \<f:uri.resource>](https://docs.typo3.org/other/typo3/view-helper-reference/main/en-us/Global/Uri/Resource.html#typo3-fluid-uri-resource)
to reference resources. You can then provide the resource path in a data
attribute:

**packages/my_extension/Resources/Private/Content/Map.fluid.html**

```html
<div
  id="myMap"
  data-icon="{f:uri.resource(extensionName: 'my_extension', path: 'Icons/Map/marker.svg')}"
  data-addresses="{f:uri.resource(extensionName: 'my_extension', path: 'XML/addresses.xml')}"
></div>

```

The file paths can then be used within JavaScript:

**packages/my_extension/Resources/Public/JavaScript/Content/Map.js**

```javascript
const myMapElement= document.getElementById('myMap');

const addresses = myMapElement.dataset.addresses;
const iconPath = myMapElement.dataset.icon;

```

If the assets lie within the same extension you can also use relative paths in
the JavaScript and CSS files.

### PHP: `PathUtility::getAbsoluteWebPath()` {#resources-public-php}

You can use the class `\TYPO3\CMS\Core\Utility\PathUtility` to get an
absolute web path for a public resource via `PathUtility::getAbsoluteWebPath()`:

**packages/my_extension/Classes/Controller/MyMapController.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Something;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;

class MyMapController
{
  public function getWebPath(string $path = 'EXT:my_extension/Resources/Public/myfile.xml'): string
  {
    // This only works in frontend context, not in CLI
    $absolutePath = GeneralUtility::getFileAbsFileName($path);
    return PathUtility::getAbsoluteWebPath($absolutePath);
  }
}

```
