I'm converting a custom component from Joomla 3, where the component was using the legacy router, to Joomla 4 router. I have the router service set up and working on Joomla 4.4.0. I first tried creating a component Router which extended the RouterView. I needed to check the output of the parse function to check which segments still needed converting to vars. However the parse function didn't get executed. The build function yes. So I tried creating a component class Router which implements the Joomla\CMS\Component\Router\RouterInterface. Again the preprocess and build function are executed but the parse function doesn't get executed. In Joomla 3 the myComponentParseRoute function would be executed when clicking on MyComponent link. The behaviour seems different in Joomla 4.

Reading the notes in the RouterInterface the parse function should be executed when SEF mode is switched on. I've SEF mode activated but in Joomla 4 when should the router parse function be executed? I've already read the book by Nicholas Dionysopoulos and viewed the Youtube videos by Robbie Jackson. Can anybody give any further tips for building and debugging the Joomla 4 component router parse function?

  • How are you checking whether the code is executed?
    – Sharky
    Nov 28, 2023 at 7:45
  • I'm using Netbeans with xdebug with break points. Nov 28, 2023 at 11:57

1 Answer 1


I read further and dug into the Joomla code, in particular the Joomla\CMS\Router file. Fairly early on, the Joomla Site Application executes the Joomla\CMS\Router->parse function which in turn executes the Joomla\CMS\SiteRouter->parseSefRoute function. It's in the parseSefRoute function where the component routers are loaded and the component router parse function is executed. For the component router parse function to be executed 2 conditions need to be met:

  1. $route variable is not empty
  2. the uri option variable (i.e. com_mycomponent) has a value. The $route variable is taken from the uri path. If the $route path is empty because there aren't any segments to be called then the Joomla component Router parse function will not be executed. This was my issue because my Joomla component Router build function wasn't generating the necessary segment variables, so the $route variable in the SiteRouter->parseSefRoute was always empty. Fixing my component's build function means my component's parse function is executed as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.