Hello. I dont understand exactly what is the difference between use init() and bootstrap() on a class.
My case:
I want to add dynamical urls from my module by using Yii::$app->urlManager->addRules(…) but NOT loading the module in order to improve the performance.
So, I thought if bootstraping the module from the main configuration file like: ‘bootstrap’ => [‘mymodule’], the Module::bootstrap() function will be executed ONLY and exclusively. But actually always runs Module::init() function, and then Module::bootstrap().
If I understand it right, the bootstrapping process takes place when the app is created, that is, before the url manager parses the requested URL into the route.
I don’t think it’s possible to add the custom url rules of a module only when the module is called, because the url manager must know how to parse the request into the module’s route in advance before actually loading the module.
For example, the request may be like this: ‘your-module/some-controller/id/some-parameter/some-action’. Then the url manager should be able to parse it into the right route and parameters of your module. Can it be possible without the custom url rules of the module?
[EDIT]
Oh, I’m sorry. I didn’t understand your question very well.
So you want to set the url rules in bootstrapping time, but don’t want to do some heavy initialization process of the module… Let me think again.