Extbase PHP attributes reference
This page is a quick-reference for all PHP attributes defined and handled by the Extbase framework itself. It covers ORM attributes (used on model properties), validation attributes (used on model properties and action parameters), and controller-level attributes (used on action methods).
It does not cover attributes defined by TYPO3 Core outside of Extbase, or PHP built-in attributes.
On this page
ORM (object relational mapping) attributes (persistence)
ORM (Object-Relational Mapping) is the mechanism that lets you work with PHP objects instead of raw database rows. Therefor Extbase maps database fields to Object Model properties and back. The attributes described below are used to control this process.
The attributes are declared in the
\TYPO3\
namespace and are placed on model properties.
#[Lazy]
- Target
-
Model property
- Fully qualified namespace
-
\TYPO3\CMS\ Extbase\ Attribute\ ORM\ Lazy - Parameters
-
none
By default, relations are resolved and processed by loading all related objects together with the parent,
which can harm performance and trigger N+1 queries, for example in list views.
# tells Extbase to load the related object only when it is actively
accessed — by calling its methods or reading its properties.
The lazy relation is a native PHP lazy object of the target class, so the property keeps its plain type and the getter needs no special handling. See Lazy loading.
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Domain\Model;
use TYPO3\CMS\Extbase\Attribute\ORM\Lazy;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
class Conference extends AbstractEntity
{
#[Lazy]
protected ?Location $location = null;
public function getLocation(): ?Location
{
return $this->location;
}
}
See also
Relations and ObjectStorage — relations and ObjectStorage on the model page.
Persistence relations — full lazy loading reference and the N+1 query trap.
#[Cascade]
- Target
-
Model property
- Fully qualified namespace
-
\TYPO3\CMS\ Extbase\ Attribute\ ORM\ Cascade - Parameters
-
string|null $value = null
Controls what happens to related objects when the parent object is deleted.
Currently only 'remove' is supported:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Domain\Model;
use TYPO3\CMS\Extbase\Attribute\ORM\Cascade;
use TYPO3\CMS\Extbase\Attribute\ORM\Lazy;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
class Conference extends AbstractEntity
{
#[Lazy]
#[Cascade('remove')]
protected ObjectStorage $comments;
}
Without
#, deleting the parent object leaves related
records in the database as orphans. With it, Extbase deletes the related
objects automatically via the repository.
Note
Only 'remove' is supported. Other Doctrine cascade operations
('persist', 'merge', etc.) are not implemented in Extbase.
Important
Cascade remove is triggered by Extbase's own persistence layer — it only
fires when you delete an object via a repository method (for example
$repository->remove). Deleting a record through the TYPO3
backend uses the DataHandler, which is unaware of
#. For
cascade behavior in backend deletions, configure the corresponding TCA
relation with the appropriate delete behavior.
#[Transient]
- Target
-
Model property
- Fully qualified namespace
-
\TYPO3\CMS\ Extbase\ Attribute\ ORM\ Transient - Parameters
-
none
Excludes a property from persistence entirely. Extbase never reads or writes the corresponding column. Use for computed values or temporary state:
Validation attributes
These attributes are declared in the
\TYPO3\ namespace
and control validation behavior on model properties and controller action parameters.
#[Validate]
- Target
-
Model property, action method parameter
- Fully qualified namespace
-
\TYPO3\CMS\ Extbase\ Attribute\ Validate - Repeatable
-
yes — apply multiple
#to one target[Validate] - Parameters
string $validator- The validator class name or short name (for example
'Not,Empty' 'String). Short names resolve against the built-in validators inLength' \TYPO3\.CMS\ Extbase\ Validation\ Validator array $options =[] - Options passed to the validator constructor. The available options depend on the validator.
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Domain\Model;
use TYPO3\CMS\Extbase\Attribute\Validate;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
class Conference extends AbstractEntity
{
#[Validate(validator: 'NotEmpty')]
#[Validate(
validator: 'StringLength',
options: ['minimum' => 3, 'maximum' => 50],
)]
protected string $title = '';
}
See also
Built-in validators — all built-in validators and their options.
Custom validators — writing a custom validator.
#[IgnoreValidation]
- Target
-
Action method parameter
- Fully qualified namespace
-
\TYPO3\CMS\ Extbase\ Attribute\ Ignore Validation - Parameters
-
none (place directly on the parameter)
Suppresses validation for one action parameter. Useful in multi-step forms where partial state is forwarded between actions:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Controller;
use MyVendor\MyExtension\Domain\Model\Conference;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Attribute\IgnoreValidation;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class ConferenceController extends ActionController
{
public function previewAction(
#[IgnoreValidation]
Conference $conference,
): ResponseInterface {
// validation skipped for $conference
return $this->htmlResponse();
}
}
Changed in version 15.0 Breaking: #109783 - Deprecated functionality removed
Extbase ignores
# on the action method. See
moving #[Validate] and #[IgnoreValidation] to parameter level.
Place
# directly on the parameter.
Controller attributes
These attributes are declared in the
\TYPO3\
namespace and are applied to controller action methods to control access and
rate limiting.
#[Authorize]
- Target
-
Controller action method
- Fully qualified namespace
-
\TYPO3\CMS\ Extbase\ Attribute\ Authorize
New in version 14.2 Feature: #107826 - Introduce Extbase action authorization attribute
Declares access requirements for an action method. Extbase checks the requirements before calling the action and answers with HTTP 403 if they are not met. See Protecting Extbase actions with #[Authorize] for the options and an example.
Warning
require and require check who the user is, not which
records the user may change. Check that a submitted record belongs to the
current user in a callback before updating or deleting it.
#[RateLimit]
- Target
-
Controller action method
- Fully qualified namespace
-
\TYPO3\CMS\ Extbase\ Attribute\ Rate Limit
New in version 14.2 Feature: #108982 - Introduce rate limiting for Extbase actions
Limits how often an action may be called within a time window, per visitor. Useful for protecting form submission endpoints against brute-force and spam. See Rate-limiting Extbase actions with #[RateLimit] for the options and an example.