Calling Developers!
We are reenergizing our code contribution process! Learn More

Can i show my custom module in frontend without modifying the RouterDependencyProvider.php file?

sunil Software Engineer Posts: 5 🧑🏻‍🚀 - Cadet

Hi Team, I have create a custom module inside src/Pyz/Yves and using that i am showing the homepage. Inside the src/Pyz/Yves/Router/RouterDependencyProvider.php, I have replaced new HomePageRouteProviderPlugin() with my custom module plugin i.e new CustomRouteProviderPlugin() and right now homepage is loading from my custom module.

Now i want to load this homepage without modifying the RouterDependencyProvider.php file.

Is their any way to call this new CustomRouteProviderPlugin() inside my custom module, so that i don't have to modify RouterDependencyProvider.php.

If yes, can you share some example code or any reference code that can help?


  • victor.vanherpt
    victor.vanherpt Spryker Solution Partner Posts: 41 🪐 - Explorer

    Good morning here @sunil!

    I believe your are replacing the HomePageRouteProviderPlugin() right?

    Rather than that, create a new one in your module (you can copy HomePageRouteProviderPlugin()), refactor it to match your needs and then add a new line in the \Pyz\Yves\Router\RouterDependencyProvider::getRouteProvider referencing your new RouteProviderPlugin().

    if you check the getRouteProvider function, it has a new function for each controller-managed route (You could also go the StorageRouter, but I guess that's another (more complicated) story :) )

    Here's \Pyz\Yves\Router\RouterDependencyProvider::getRouteProvider:
    protected function getRouteProvider(): array

        return [
            # (... Other route plugins)
    new HomePageRouteProviderPlugin(),
            # (... Other route plugins)
    new MyNewControllerRouteProviderPlugin(),


  • sunil
    sunil Software Engineer Posts: 5 🧑🏻‍🚀 - Cadet

    These are the screenshot of my code structure.

    Now i want to make this homepage running without modifying RouterDependencyProvider.php file / adding this line new CustomRouteProviderPlugin() in the RouterDependencyProvider.php

    Is their any way to add this line inside my custom module, as i want this module to be independent module.

    And also can you share some example or reference code.

  • Salmanali Agharia
    Salmanali Agharia Software Engineer Posts: 7 🧑🏻‍🚀 - Cadet

    Hi @sunil ,

    Registering your routes is compulsory action so that application can know which action ( in our case indexAction() )to perform when a new request is received. RouterDependencyProvider basically adds your provided routes in routeCollection. You can't ignore this step if you want your custom url to work. Router in itself is a separate module for manging routing in Spryker, so you should not move it's logic in your custom module.

    Reference :-