The following are some useful global function available in the generated code for you to work with server events easily:
``Get()``
``Get(string $name, mixed $default = null): mixed``
Get a query string parameter from ``$_GET``. If the value is not set, the default value ``$default`` (``null`` by default) is returned.
``GetBool()``
``GetBool(string $key, ?bool $default = null): ?bool``
Returns the query string parameter value converted to boolean
``GetInt()``
``GetInt(string $key, ?int $default = null): ?int``
Returns the query string parameter value converted to integer
``GetString()``
``GetString(string $key, ?string $default = null): ?string``
Returns the query string parameter value converted to string
``Post()``
``Post(string $name, mixed $default = null): mixed``
Get a body parameter value from ``$_POST``. If the value is not set, the default value ``$default`` (``null`` by default) is returned.
``PostBool()``
``PostBool(string $key, ?bool $default = null): ?bool``
Returns the body parameter value converted to boolean
``PostInt()``
``PostInt(string $key, ?int $default = null): ?int``
Returns the body parameter value converted to integer
``PostString()``
``PostString(string $key, ?string $default = null): ?string``
Returns the body parameter value converted to string
``Param()``
``Param(string $name, mixed $default = null): mixed``
Get a value from ``$_POST``. If not set, get the value from ``$_GET``. If still not set, the default value ``$default`` (``null`` by default) is returned.
``ParamBool()``
``ParamBool(string $key, ?bool $default = null): ?bool``
Returns the parameter value (from `$_POST` or `$_GET`) converted to boolean
``ParamInt()``
``ParamInt(string $key, ?int $default = null): ?int``
Returns the parameter value (from `$_POST` or `$_GET`) converted to integer
``ParamString()``
``ParamString(string $key, ?string $default = null): ?string``
Returns the parameter value (from `$_POST` or `$_GET`) converted to string
``IsGet()``
``IsGet(): bool``
Check if current request Is GET request
``IsPost()``
``IsPost(): bool``
Check if current request Is POST request
``Config()``
``Config(mixed ...$args): mixed``
Get/Set config. If value is of array type, **dot notation access** is supported.
``Log()``
``Log(string $msg, array $context = []): void``
Log debug information to the log file. The first argument ``$message`` is a string or an object with a ``__toString()`` method, see [Message](https://www.php-fig.org/psr/psr-3/#12-message) for details.
Note that the optional second argument ``$context`` is an ARRAY for adding extra information along the textual message, the array can contain anything. A given value in the context MUST NOT throw an exception nor raise any php error, warning or notice. See [Context](https://www.php-fig.org/psr/psr-3/#13-context) for details.
``Route()``
``Route(?string $name = null): ?string``
Get the route value by name. If ``$name`` unspecified, all route values are returned as array.
For example, if route is ``/api/hello/{name}`` and the request is ``/api/hello/world``:
``RouteAction()``
``RouteAction(?Request $request = null): ?string``
Get route action of a request (default is current request):
- For routes starting with `/api/`, it returns the second segment (typically the API action).
- For other routes, it returns the first segment.
- Returns null if the path is empty or has no relevant segments.
``RouteName()``
``RouteName(?Request $request = null): ?string``
Get current route name (defined by route attributes).
``GetRoute()``
``GetRoute(?string $routeName = null): ?Route``
Get route by route name. If route name unspecifed, default is corrent route name.
``UrlGenerator()``
``UrlGenerator(): UrlGeneratorInterface``
Get URL generator, see [Generating URLs](https://symfony.com/doc/current/routing.html#generating-urls).
To generate a URL, you need to specify the route name and the values of the parameters defined by the route attributes.
``UrlFor()``
``UrlFor(?string $routeName, array $parameters = [], array $queryParams = []): string``
Get URL from route name
``FullUrlFor()``
``FullUrlFor(?string $routeName, array $parameters = [], array $queryParams = []): string``
Get full URL from route name
``BasePath()``
``BasePath(bool $withTrailingDelimiter = false): string``
Get base path
``AppUrl()``
``AppUrl(bool $withTrailingDelimiter = false): string``
Get app URL (domain URL + base path)
``IsApi()``
``IsApi(): bool``
Check if current request is API request
``IsModal()``
``IsModal(): bool``
Check if current request if for modal dialog
``IsAjaxRequest()``
``IsAjaxRequest(?Request $request = null): bool``
Check if a request is AJAX request
``IsJsonResponse()``
``IsJsonResponse(?Response $response = null): bool``
Check if the current request expects JSON response or the provided response is JSON response
``DecodeJwt()``
``DecodeJwt(string $token): ?array``
Decode JWT token manually
``Conn()``
``Conn(string $dbid = "DB"): Connection``
Get the global connection object. If ``$dbname`` is not specified, it returns the connection object for the database of the project. If ``$dbname`` is specified, it returns the connection object for the specified database of a Linked Table.
The connection object contains several methods for executing queries against your configured database for [data retrieval and manipulation](https://www.doctrine-project.org/projects/doctrine-dbal/en/4.3/reference/data-retrieval-and-manipulation.html#api):
``Security()``
``Security(): AdvancedSecurity``
Get the advanced security service.
``Language()``
``Language(): Language``
Get the language service.
``Profile()``
``Profile(array ...$args): mixed``
Get the user profile service.
``Session()``
``Session(mixed ...$args): mixed``
Get the Symfony [session](https://symfony.com/doc/current/session.html) object, or get/set attribute(s).
``CurrentUser()``
``CurrentUser(): ?UserInterface``
Get current user. If the user is a database user, it is an entity of the user table.
``CurrentUserName()``
``CurrentUserName(): string``
Get current user name.
``CurrentUserEmail()``
``CurrentUserEmail(): ?string``
Get current user email. Requires [Email Field](securitysetup.html#options) enabled.
``CurrentUserID()``
``CurrentUserID(): mixed``
For used with User ID Security (see [Security Settings](securitysetup.html)). Get current User ID.
``CurrentUserLevel()``
``CurrentUserLevel(): int|string``
For used with User Level Security (see [Security Settings](securitysetup.html)). Get current user's User Level ID. Note that this is NOT the current user's permission.
``CurrentUserInfo()``
``CurrentUserInfo(string $fldname): mixed``
For used with Advanced Security (see [Security Settings](securitysetup.html)). Get current user's info from the user table. The argument is the field name in the user table.
``CurrentPageID()``
``CurrentPageID(): string``
Get current page ID. A page ID identifies the page type, it can be "list", "view", "add", "edit", "delete", "search", etc.
``CurrentPage()``
CurrentPage(): ?PageInterface
Get current page object.
``CurrentPageName()``
``CurrentPageName(): string``
Get current page (route) name without path.
``CurrentPageTitle()``
``CurrentPageTitle(?string $value = null): string``
Get/Set current page title.
``CurrentTable()``
CurrentTable(): ?PageInterface
Alias of `CurrentPage()`
``CurrentTableName()``
``CurrentTableName(): string``
Get current table name.
``CurrentLanguageID()``
``CurrentLanguageID(): string``
Get current language ID.
``IsRTL()``
``IsRTL(): bool``
Check if current language is RTL.
Deprecated ``Page()``
Page(string $name = ""): ?object
Get table/page object of another table in the page, e.g. the table object of the master table or the **grid** page object of a detail table. If ``$name`` is not specified, it returns ``CurrentPage()``. If the table/page object is not initiated, it returns `null`.
**This function is deprecated and will be removed in next major version.** You can use `CurrentPage()`, `CurrentMasterTable()` and `CurrentDetailTable()` instead.
``Container()``
``Container(mixed ...$args): mixed``
Get (or create if not exist) service.
``ServiceLocator()``
``ServiceLocator(?string $id = null): mixed``
Get (or create if not exist) service from the service locator of the application. The service locator limits access to only specified services, fetches some private services from container, and supports lazy loading, making it safer and more efficient than using the full container directly. To add an **existing** service to the service locator, you can use `AddServiceId()` (see below).
``AddServiceId()``
``AddServiceId(string $id, ?string $serviceId = null): void``
Add an **existing** service to the service locator.
``IsLoggedIn()``
``IsLoggedIn(): bool``
For used with Advanced Security (see [Security Settings](securitysetup.html)). Get the login status of the current user.
``IsEntityUser()``
``IsEntityUser(?UserInterface $user = null): bool``
Check if the given user (or current user if null) is an Entity user.
``IsAdmin()``
``IsAdmin(): bool``
Check if the current user is an administrator (super admin or users from the Administrator user level).
``IsSysAdminUser()``
``IsSysAdminUser(?UserInterface $user = null): bool``
Check if the given user (or current user if null) is the super admin user.
``IsWindowsUser()``
``IsWindowsUser(?UserInterface $user = null): bool``
Check if the given user (or current/profile user if null) is a Windows user.
``IsAccessTokenUser()``
``IsAccessTokenUser(?UserInterface $user = null): bool``
Check if the given user (or current/profile user if null) is an access token (SAML2) user.
``IsOAuthUser()``
``IsOAuthUser(?UserInterface $user = null): bool``
Check if the given user (or current/profile user if null) is an OAuth user.
``IsLdapUser()``
``IsLdapUser(?UserInterface $user = null): bool``
Check if the given user (or current/profile user if null) is an LDAP user.
``IsAuthenticated()``
``IsAuthenticated(): bool``
Check if there is a currently authenticated user.
Returns true if `CurrentUser()` implements `UserInterface`, false otherwise.
``IsGranted()``
``IsGranted(mixed $attributes, mixed $subject = null): bool``
Check if the attributes are granted against the current authentication token and optionally supplied subject, e.g.
``IsImpersonator()``
``IsImpersonator(): bool``
Check if the current user is impersonating another user, e.g.
``OriginalUser()``
``OriginalUser(): ?UserInterface``
Get the original user when impersonating another user, e.g.
``IsExport()``
``IsExport(string $format = ""): bool``
Check if the page is exporting data.
``ExecuteQuery()``
``ExecuteQuery(string $sql, Connection|string|null $c = null): \Doctrine\DBAL\Result``
Executes SELECT statement and returns the [Doctrine\DBAL\Result](https://github.com/doctrine/dbal/blob/3.6.x/src/Result.php) instance for accessing the results by [fetch API](https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/data-retrieval-and-manipulation.html#using-prepared-statements).
``ExecuteStatement()``
``ExecuteStatement(string $sql, Connection|string|null $c = null): int``
Executes UPDATE, INSERT, or DELETE statements and returns number of rows affected.
``ExecuteRow()``
``ExecuteRow(string $sql, Connection|string|null $c = null, int $mode = \PDO::FETCH_ASSOC): mixed``
Executes the query, and returns the first row as an array.
``ExecuteRows()``
``ExecuteRows(string $sql, Connection|string|null $c = null, int $mode = \PDO::FETCH_ASSOC): array|false``
Executes the query, and returns the rows as an array.
``ExecuteScalar()``
``ExecuteScalar(string $sql, Connection|string|null $c = null): mixed``
Executes the query, and returns the first column of the first row.
``ExecuteHtml()``
``ExecuteHtml(string $sql, ?array $options = null, Connection|string|null $c = null): string``
Executes the query, and returns the data as HTML table. See source code for options.
``ExecuteJson()``
``ExecuteJson(string $sql, array|bool|null $options = null, Connection|string|null $c = null): string``
Executes the query, and returns the data as JSON. See source code for options.
``QueryBuilder()``
``QueryBuilder(string $dbid = "DB"): QueryBuilder``
Create a **DBAL** [QueryBuilder](https://www.doctrine-project.org/projects/doctrine-dbal/en/current/reference/query-builder.html) for the database connection.
``EntityManager()``
``EntityManager(string $dbid = "DB"): EntityManager``
Get the [EntityManager](https://www.doctrine-project.org/projects/doctrine-orm/en/3.2/reference/architecture.html#the-entitymanager) object.
If ``$dbname`` is not specified, it returns the entity manager object for the database of the project. If ``$dbname`` is specified, it returns the entity manager object for the specified database of a Linked Table.
For example, if a table from the main database is named "Users", the entity class name is the singular form "User". The class is ``Db\Entity\User`` under the namespace of the project. If the table is a linked table, the entity is under the linked table's name space, e.g. ``DbVarName\Entity\MyEntity``. Note that the namespace of the database and the entity are in **Pascal case**.
``GetRepository()``
``GetRepository(string $entityClass): ObjectRepository``
Get entity repository by entity class name.
``SetClientVar()``
``SetClientVar(string $key, mixed $value): void``
Pass server side data to client side as a property of the ``ew.vars`` object.
``CreateLoginLink()``
``CreateLoginLink(UserInterface $user, ?int $lifetime = null): LoginLinkDetails``
Create a passwordless [Login Link](authentication.html?id=login-link).
``Nonce()``
``Nonce(): string``
Returns nonce attribute if [Use nonce (strict CSP)](tools.html?id=use-nonce-strict-csp) is enabled, e.g. ``nonce="mDFOblRcXBin0EPgL3bInkIQ"``.
``SendSmsNotification()``
``SendSmsNotification(#[\SensitiveParameter] string $phone, string $content, mixed $region = null, int $format = 0): bool|string``
Send SMS notification. Note that the [SmsNotifier](extension.html?id=additional-extensions-and-custom-view-tags-for-registered-users) extension(for registered users only) must be enabled and you must subscribe to a third party SMS service and retrieve the credentials for the integration.
``SendEmailNotification()``
``SendEmailNotification(#[\SensitiveParameter] string $email, string $subject, string $content): bool|string``
Send simple email notification. Note that the [Email Settings](phpsetup.html?id=email-settings) must be properly set up.
``SendEmail()``
``SendEmail(string $fromEmail,``
`` string $toEmail,``
`` string $ccEmail,``
`` string $bccEmail,``
`` string $subject,``
`` string $mailContent,``
`` string $format = "html",``
`` string $charset = EMAIL_CHARSET,``
`` int|string $priority = 3,``
`` array $attachments = [],``
`` array $images = []``
``): string|bool``
Send email. Note that:
1. [Email Settings](phpsetup.html?id=email-settings) must be properly set up.
1. If you send attachments, you should provide full paths, or you can use relative paths if you place the images in the global [upload folder](phpsetup.html?id=file-upload). If you provide the attachment content as string, you can use
["filename" => $filename, "content" => $content] instead of file path for that attachment.
1. If you embed images, you should provide full paths, or you can use relative paths if you place the images in the global [upload folder](phpsetup.html?id=file-upload). Then you can use ``

`` in your email content, where ``{ContentId}`` can be obtained by ``GetContentId($image)``.
``SendWebPushNotification()``
``SendWebPushNotification(SubscriptionInterface $subscription, array|string $payload, array $options = [], array $auth = []): MessageSentReport``
Send web push notification
``PeekFailureMessage()``
``PeekFailureMessage(): array``
Peek failure message without removing it from the flash bag.
``GetFailureMessage()``
``GetFailureMessage(): string``
Get and remove all failure messages, joined by ``
``.
``SetFailureMessage()``
``SetFailureMessage(string|array $msg): void``
Replace all failure messages with the given message or message array.
``AddFailureMessage()``
``AddFailureMessage(mixed $msg): void``
Add a new failure message to the flash bag without removing existing ones.
``PeekWarningMessage()``
``PeekWarningMessage(): array``
Peek warning messages (stored under `warning`) without removing them.
``GetWarningMessage()``
``GetWarningMessage(): string``
Get and remove all warning messages (stored under `warning`), joined with `
`.
``SetWarningMessage()``
``SetWarningMessage(string|array $msg): void``
Replace all warning messages under the `warning` flash bag key.
``AddWarningMessage()``
``AddWarningMessage(mixed $msg): void``
Add a new warning message under the `warning` flash bag key.
``PeekSuccessMessage()``
``PeekSuccessMessage(): array``
Peek success messages (stored under `success`) without removing them.
``GetSuccessMessage()``
``GetSuccessMessage(): string``
Get and remove all success messages (stored under `success`), joined with `
`.
``SetSuccessMessage()``
``SetSuccessMessage(string|array $msg): void``
Replace all success messages under the `success` flash bag key.
``AddSuccessMessage()``
``AddSuccessMessage(mixed $msg): void``
Add a new success message under the `success` flash bag key.
``SendBrowserNotification()``
``SendBrowserNotification(string $message, string $importance = Notification::IMPORTANCE_MEDIUM): void``
Send a browser notification via Symfony's ``browser`` channel.
The notification is stored in the session flash bag using a key that matches **Bootstrap alert classes**, making it easy to render as Bootstrap alerts without extra logic.
**How It Works**
* The message is sent through Symfony's `BrowserChannel`.
* The `BootstrapFlashMessageImportanceMapper` maps the notification's importance to a flash bag key.
* The mapped key matches a Bootstrap alert type, e.g., `success`, `info`, `warning`, or `danger`.
* The function is equivalent to `AddXxxMessage()`. This allows you to use existing functions like `GetFailureMessage()`.
**Importance Mapping**
| Notification Constant / String Value | FlashBag Key / Bootstrap Class |
|--------------------------------------------|--------------------------------|
| `Notification::IMPORTANCE_LOW` / `'low'` | `success` |
| `Notification::IMPORTANCE_MEDIUM` / `'medium'` | `info` |
| `Notification::IMPORTANCE_HIGH` / `'high'` | `warning` |
| `Notification::IMPORTANCE_URGENT` / `'urgent'` | `danger` |
Since the notifications are stored under the same flash bag keys, you can reuse above functions: `PeekXxxMessage()`, `GetXxxMessage()`, `SetXxxMessage()` and `AddXxxMessage()`.
``AddListener()``
``AddListener(string $eventName, callable|array $listener, int $priority = 0)``
For use with [Event Listeners](customscripts.html?id=event-listeners). The ``AddListener()`` method takes up to three arguments:
1. The event name (string) that this listener wants to listen to;
1. A PHP callable that will be executed when the specified event is dispatched;
1. An optional priority, defined as a positive or negative integer (defaults to 0). The higher the number, the earlier the listener is called. If two listeners have the same priority, they are executed in the order that they were added to the dispatcher.
**Note** If you have many listeners, it is better to create an **event subscriber** by [Custom Files](customfile.html?id=add-your-own-classes) instead.
``DispatchEvent()``
``DispatchEvent(Event $event, ?string $eventName = null): object``
Dispatch an event.
``IsDevelopment()``
``IsDevelopment(): bool``
Check if the application is running in development environment.
``IsProduction()``
``IsProduction(): bool``
Check if the application is running in production environment.
``IsDebug()``
``IsDebug(): bool``
Check if the application is running in debug mode.
``VarDump()``
``function VarDump(mixed ...$values): string``
Dump one or more variables as HTML using Symfony VarDumper,
returning the output as a string. Automatically injects a CSP-safe `nonce` into
all `style` and `script` tags to ensure compliance with Content Security Policies.
``RequestStack()``
``RequestStack(): ?RequestStack``
Get current request stack object.
``Request()``
``Request(): Request``
Get current request object.