---
title: "Enumerations"
manual: "schema"
version: "main"
permalink: "https://docs.typo3.org/permalink/brotkrueml/schema:enumerations@main"
source: "Developer/Enumerations.rst"
rendered: "2026-09-25T08:33:13+00:00"
---

# Enumerations {#enumerations}

Target group: **Integrators, Developers**

**Table of Contents**

-   [Introduction](https://docs.typo3.org/permalink/brotkrueml/schema:introduction@main)
-   [Usage in PHP](https://docs.typo3.org/permalink/brotkrueml/schema:usage-in-php@main)
-   [Usage in Fluid templates](https://docs.typo3.org/permalink/brotkrueml/schema:usage-in-fluid-templates@main)
-   [Create your own enumeration type](https://docs.typo3.org/permalink/brotkrueml/schema:create-your-own-enumeration-type@main)

## Introduction {#introduction}

The schema.org vocabulary provides [enumerations types](https://schema.org/Enumeration). An enumeration has
one or more members, for example, the `GenderType` used for the `gender` property
has the members `Male` and `Female`.

These enumerations can be used in your code instead of plain strings. This has
the advantage of avoiding typos because you can use your IDE's capabilities.
Also these members are part of a common vocabulary.

You can find the enums provided by the TYPO3 schema extensions in the
`Classes/Model/Enumeration/` folder.

## Usage in PHP {#usage-in-php}

Usage in PHP is straightforward, in this example we are using the
`\Brotkrueml\Schema\Model\Enumeration\GenderType` enum in the
`gender` property:

**EXT:my_extension/Classes/Controller/MyController.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Controller;

use Brotkrueml\Schema\Model\Enumeration\GenderType;
use Brotkrueml\Schema\Type\TypeFactory;

final class MyController
{
    public function __construct(
        private readonly TypeFactory $typeFactory,
    ) {}

    public function doSomething(): void
    {
        // ...

        $person = $this->typeFactory->create('Person');
        $person
            ->setId('https://example.org/#person-42')
            ->setProperty('givenName', 'John')
            ->setProperty('familyName', 'Smith')
            ->setProperty('gender', GenderType::Male);

        // ...
    }
}

```

This results in the following output:

```json
{
   "@context": "https://schema.org/",
   "@type": "Person",
   "@id": "https://example.org/#person-42",
   "givenName": "John",
   "familyName": "Smith",
   "gender": "https://schema.org/Male",
}
```

## Usage in Fluid templates {#enumerations-view-helper}

The example in the PHP section above can also be adapted for a Fluid template.
We make use of the [constant view helper](https://docs.typo3.org/other/typo3/view-helper-reference/14.3/en-us/Global/Constant.html#typo3fluid-fluid-constant)
(which is available since Fluid v2.12):

```html
<schema:type.person
   -id="https://example.org/#person-42"
   givenName="John"
   familyName="Smith"
   gender="{f:constant(name: '\Brotkrueml\Schema\Model\Enumeration\GenderType::Male')}"
/>
```

This results in the following output:

```json
{
   "@context": "https://schema.org/",
   "@type": "Person",
   "@id": "https://example.org/#person-42",
   "givenName": "John",
   "familyName": "Smith",
   "gender": "https://schema.org/Male",
}
```

## Create your own enumeration type {#create-your-own-enumeration-type}

Not all enumerations defined by schema.org are provided by this extension (or by
the [section extensions](https://docs.typo3.org/permalink/brotkrueml/schema:vocabulary@main)), but only those who have at least
one member defined by schema.org. You may find a schema.org enumeration type
which references members from the `GoodRelations` or from other vocabularies.
If you need them, you can create a custom enum.

Have a look into [Add a new enumeration](https://docs.typo3.org/permalink/brotkrueml/schema:extending-adding-enumeration@main).
