Difference between extensions and modules

Hi there

What is main difference between Modules and Extensions? I know Module is like a small application in our application and Extension is like a feature to show ready to use feature, but I don’t know where to use each one! Would you please give me some example of each uses?

thanks in advance.

Think about this in another way:

Modules, Widgets, Behaviors, etc can all be customized and released as extensions.

An ‘extension’ is just a word for a packaged ‘something’ that you can install, usually by using Composer.

So, that means that a module can be an ‘extension’.


You mean we can create a module and finally convert it to an extension? If yes, so why they are separated in Yii guide and also in Gii tool?

Because extensions are redistributable and installable - in other words: packaged.

Take the Gii extension. That is a module, actually, but packaged as an extension so that it can be installed. :)

So, extensions are things that can be reused/shared.

They would be Composer packages that can be hosted on Packagist, but they also can make use of the special Yii2 Composer extensions that allows Yii to bootstrap them, etc.

Check out the source code for the Gii extension - you should have it in your vendor directory. vendor/yiisoft/yii…

I hope that answers your question.

I haven’t used the Gii extension tool myself as I prefer to do it manually, but I probably should. ;)