How to override yii2 web.php file in config in the module

Hi, to all. Am developing a rest api application using yii2 basic template. Am planning to have multiple apis for different sites and each site will be represented as a main module in the application and within it, I will have sub modules represented by api versioning as v1. My main issue is that I dont want to mess up with the working of the normal site but only override the web.php file in the main site config with one called api.php that has rest apis settings. Seems to be simple but can’t get my head around it. Please help to solve this issue.

Maybe this can help you.

public function init()



    // initialize the module with the configuration loaded from config.php

    \Yii::configure($this, require(__DIR__ . '/config.php'));


This tricky did not work. But I created a mini app called api and adjusted some settings for it to work. It’s working. I got alot of things I was missing from this blog,