PHP Joomla! 6 Joomla! 5 Joomla! 3 (Legacy) Component Basic

Redirect with a Flash Message Using enqueueMessage() and redirect()

Queues typed system messages (success, warning, error, info) and redirects cleanly with HTTP 303 or 301 status codes.

Updated on 24 November 2026 36 copies 137 views
components/com_example/src/Controller/ItemController.php
<?php

declare(strict_types=1);

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;

$app = Factory::getApplication();
$app->enqueueMessage(Text::_('COM_EXAMPLE_SAVED_OK'), 'success');
$app->redirect(Route::_('index.php?option=com_example&view=items', false), 303);
Pass an explicit HTTP status code (303 after POST, 301 for permanent SEO redirects).
components/com_example/src/Controller/ItemController.php
<?php
$app = JFactory::getApplication();
$app->redirect(JRoute::_('index.php?option=com_example&view=items', false), JText::_('COM_EXAMPLE_SAVED_OK'), 'message');
Legacy Joomla 3 redirect syntax with message parameter.

Technical explanation and best practices

In Joomla 5 and 6, call $app->enqueueMessage() first and then pass the HTTP status code to $app->redirect($url, 303) instead of the deprecated message argument on redirect.

Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.