Skip to content
PHP Ecosystem
Explore

Manager

API reference › Inertia › Manager

final classyii\inertia\Manager
Extendsyii\base\Component » yii\base\BaseObject
Implementsyii\base\Configurable
Sourcesrc/Manager.php

Server-side Yii adapter registered as the inertia application component.

Adapts Yii requests, application state, views, sessions, and responses to the framework-agnostic protocol core.

PropertyTypeDescriptionDefined by
$behaviors read-onlyarray<yii\base\Behavior<static>>List of behaviors attached to this component.yii\base\Component
$clearHistoryboolWhether rendered pages clear the client-side history. Default: false.Manager
$encryptHistoryboolWhether rendered pages encrypt their client-side history state. Default: false.Manager
$errorFlashKeystringSession flash key exposed as props.errors in every page payload. Default: 'errors'.Manager
$eventDispatcherPsr\EventDispatcher\EventDispatcherInterface|nullPSR-14 dispatcher the default protocol emits ProtocolResultCreated through, or null to emit no events. Default: null.Manager
$exposeSharedPropsboolWhether rendered pages expose shared-prop metadata. Default: true.Manager
$idstringRoot element DOM id used by the default root view. Default: 'app'.Manager
$pageObserverPHPForge\Inertia\ResolvedPageObserver|nullOptional portable observer notified after page resolution and before response serialization. Default: null.Manager
$preserveFragmentboolWhether rendered pages preserve the URL fragment. Default: false.Manager
$protocolPHPForge\Inertia\Protocol|nullProtocol service, or null to build the default one with $eventDispatcher. Default: null.Manager
$rootViewstringRoot view file rendered for the initial HTML response. Default: '@inertia/views/app.php'.Manager
$sharedarray<string, mixed>Shared props applied to every rendered page in the current request. Default: [].Manager
$versionClosure(): int|string|null|Closure(yii\web\Request): int|string|null|int|string|nullAsset version used for client-side mismatch detection through the page version field. Default: null.Manager
MethodDescriptionDefined by
__construct()Constructor.yii\base\BaseObject
__call()Calls the named method which is not a class method.yii\base\Component
__clone()This method is called after the object is created by cloning an existing one.yii\base\Component
__get()Returns the value of a component property.yii\base\Component
__isset()Checks if a property is set, i.e. defined and not null.yii\base\Component
__set()Sets the value of a component property.yii\base\Component
__unset()Sets a component property to be null.yii\base\Component
attachBehavior()Attaches a behavior to this component.yii\base\Component
attachBehaviors()Attaches a list of behaviors to the component.yii\base\Component
behaviors()Returns a list of behaviors that this component should behave as.yii\base\Component
canGetProperty()Returns a value indicating whether a property can be read.yii\base\Component
canSetProperty()Returns a value indicating whether a property can be set.yii\base\Component
className() staticReturns the fully qualified name of this class.yii\base\BaseObject
detachBehavior()Detaches a behavior from the component.yii\base\Component
detachBehaviors()Detaches all behaviors from the component.yii\base\Component
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.yii\base\Component
flushShared()Removes all shared props.Manager
getBehavior()Returns the named behavior object.yii\base\Component
getBehaviors()Returns all behaviors attached to this component.yii\base\Component
getShared()Returns all shared props or a nested value using dot notation.Manager
getVersion()Resolves the configured asset version.Manager
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.yii\base\Component
hasMethod()Returns a value indicating whether a method is defined.yii\base\Component
hasProperty()Returns a value indicating whether a property is defined for this component.yii\base\Component
init()Initializes the object.yii\base\BaseObject
isInertiaRequest()Returns whether a request carries the Inertia request marker.Manager
location()Returns an Inertia location response or a standard redirect response.Manager
normalizeResponse()Normalizes a Yii response immediately before it is sent to an Inertia client.Manager
off()Detaches an existing event handler from this component.yii\base\Component
on()Attaches an event handler to an event.yii\base\Component
render()Renders an Inertia page through the framework-agnostic protocol core.Manager
share()Registers props shared with subsequent page responses in the current request.Manager
trigger()Triggers an event.yii\base\Component
public Psr\EventDispatcher\EventDispatcherInterface|null $eventDispatcher = null

PSR-14 dispatcher the default protocol emits ProtocolResultCreated through, or null to emit no events.

Ignored when $protocol is configured. A debugger registers its collector here.

public PHPForge\Inertia\Protocol|null $protocol = null

Protocol service, or null to build the default one with $eventDispatcher.

Configure this property to inject a custom core clock for deterministic tests.

public function flushShared(): void

Removes all shared props.

public function getShared(string|null $key = null, mixed $default = null): mixed

Returns all shared props or a nested value using dot notation.

Parameters

ParameterTypeDescription
$keystring|nullDot-notated key to retrieve, or null to return every shared prop.
$defaultmixedValue returned when $key does not exist.

Returns

mixed: Shared value at $key, or $default when the key does not exist.

public function getVersion(): int|string

Resolves the configured asset version.

Returns

int|string: Resolved version, or an empty string when no version is configured.

public function isInertiaRequest(yii\web\Request|null $request = null): bool

Returns whether a request carries the Inertia request marker.

Parameters

ParameterTypeDescription
$requestyii\web\Request|nullRequest to inspect, or null to use the current application request.

Returns

bool: true when the request is Inertia-driven; otherwise, false.

public function location(array<array-key, mixed>|string $url): yii\web\Response

Returns an Inertia location response or a standard redirect response.

Parameters

ParameterTypeDescription
$urlarray<array-key, mixed>|stringDestination URL or route array accepted by Url::to().

Returns

yii\web\Response: Yii response containing the protocol location or redirect result.

Throws

public function normalizeResponse(yii\web\Response $response): void

Normalizes a Yii response immediately before it is sent to an Inertia client.

Parameters

ParameterTypeDescription
$responseyii\web\ResponseOutgoing Yii response to normalize.

Throws

public function render(string $component, array<string, mixed> $props = [], array<string, mixed> $viewData = []): yii\web\Response

Renders an Inertia page through the framework-agnostic protocol core.

Returns a JSON page payload for Inertia requests or the initial HTML document for standard browser requests.

Parameters

ParameterTypeDescription
$componentstringClient-side component name.
$propsarray<string, mixed>Page-specific props.
$viewDataarray<string, mixed>Additional data available to the initial root view.

Returns

yii\web\Response: Yii response containing the initial HTML document or Inertia JSON page.

Throws

public function share(array<string, mixed>|string $key, mixed $value = null): void

Registers props shared with subsequent page responses in the current request.

Parameters

ParameterTypeDescription
$keyarray<string, mixed>|stringShared values or a dot-notated prop key.
$valuemixedValue registered when $key is a string.