---
title: "Annotations"
manual: "TYPO3 Explained"
version: "11.5"
permalink: "https://docs.typo3.org/permalink/t3coreapi:extbase-annotations@11.5"
source: "ExtensionArchitecture/Extbase/Reference/Annotations.rst"
rendered: "2026-10-21T15:30:00+00:00"
---

> [!WARNING]
> **Attention**
>
> TYPO3 v11 has reached end-of-life as of October 31th 2024 and
> is no longer being maintained. Use the version switcher on the top
> left of this page to select documentation for a supported version of TYPO3.
>
> Need more time before upgrading?
> You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here:
> [TYPO3 ELTS](https://typo3.com/services/extended-support-elts).

# Annotations {#extbase-annotations}

All available annotations for Extbase delivered by TYPO3 Core are placed within
the namespace `\TYPO3\CMS\Extbase\Annotation`.

Example in the blog example for the annotation `Lazy`:

**EXT:blog_example/Classes/Domain/Model/Post.php**

```php
use TYPO3\CMS\Extbase\Annotation\ORM\Lazy;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

class Post extends AbstractEntity
{
    /**
     * @var ObjectStorage<Post>
     * @Lazy
     */
    public ObjectStorage $relatedPosts;
}
```

## Annotations provided by Extbase {#annotations-provided-by-extbase}

The following annotations are provided Extbase:

### Validate {#extbase-annotation-validate}

`@TYPO3\CMS\Extbase\Annotation\Validate`: Allows to configure validators
for properties and method arguments. See [Validation](https://docs.typo3.org/permalink/t3coreapi:extbase-validation@11.5) for details.

Can be used in the context of a model property.

**Example:**

**EXT:blog_example/Classes/Domain/Model/Blog.php**

```php
use TYPO3\CMS\Extbase\Annotation\Validate;

class Blog extends AbstractEntity
{
    /**
     * A short description of the blog
     *
     * @Validate("StringLength", options={"maximum": 150})
     */
    public string $description = '';
}
```

### IgnoreValidation {#extbase-annotation-ignore-validation}

`@TYPO3\CMS\Extbase\Annotation\IgnoreValidation()`: Allows to ignore
Extbase default validation for a given argument.

Used in context of a controller action.

**Example:**

**EXT:blog_example/Classes/Controller/BlogController.php**

```php
use FriendsOfTYPO3\BlogExample\Domain\Model\Blog;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Annotation\IgnoreValidation;

class BlogController extends AbstractController
{
    /**
     * Displays a form for creating a new blog
     *
     * @IgnoreValidation("newBlog")
     */
    public function newAction(?Blog $newBlog = null): ResponseInterface
    {
        $this->view->assign('newBlog', $newBlog);
        $this->view->assign(
            'administrators',
            $this->administratorRepository->findAll()
        );
        return $this->htmlResponse();
    }
}
```

### ORM (object relational model) annotations {#extbase-annotation-orm}

The following annotations can only be used on model properties:

#### Cascade {#extbase-annotation-cascade}

`@TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")`: Allows to remove
child entities during deletion of aggregate root.

Extbase only supports the option "remove".

**Example:**

**EXT:blog_example/Classes/Domain/Model/Blog.php**

```php
use TYPO3\CMS\Extbase\Annotation\ORM\Cascade;
use TYPO3\CMS\Extbase\Annotation\ORM\Lazy;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

class Blog extends AbstractEntity
{
    /**
     * The posts of this blog
     *
     * @var ObjectStorage<Post>
     * @Lazy
     * @Cascade("remove")
     */
    public $posts;
}
```

#### Transient {#extbase-annotation-transient}

`@TYPO3\CMS\Extbase\Annotation\ORM\Transient`: Marks property as transient
(not persisted).

**Example:**

**EXT:blog_example/Classes/Domain/Model/Person.php**

```php
use TYPO3\CMS\Extbase\Annotation\ORM\Transient;

class Person extends AbstractEntity
{
    /**
     * @Transient
     */
    protected string $fullname = '';
}
```

#### Lazy {#extbase-annotation-lazy}

`@TYPO3\CMS\Extbase\Annotation\ORM\Lazy`: Marks property to be lazily
loaded on first access.

> [!NOTE]
> Lazy loading can greatly improve the performance of your actions.

**Example:**

**EXT:blog_example/Classes/Domain/Model/Post.php**

```php
use TYPO3\CMS\Extbase\Annotation\ORM\Lazy;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

class Post extends AbstractEntity
{
    /**
     * @var ObjectStorage<Post>
     * @Lazy
     */
    public ObjectStorage $relatedPosts;
}
```

## Combining annotations {#extbase-annotation-combine}

Annotations can be combined. For example, "lazy loading" and "removal on cascade"
are frequently combined:

**EXT:blog_example/Classes/Domain/Model/Post.php**

```php
use TYPO3\CMS\Extbase\Annotation\ORM\Cascade;
use TYPO3\CMS\Extbase\Annotation\ORM\Lazy;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

class Post extends AbstractEntity
{
    /**
     * @var ObjectStorage<Comment>
     * @Lazy
     * @Cascade("remove")
     */
    public ObjectStorage $comments;
}
```

Several validations can also be combined. See [Validation](https://docs.typo3.org/permalink/t3coreapi:extbase-validation@11.5)
for details.
