Reusable Module As Extension

Guys,

which is the best way to developing a reusable module as an extension?

I create an extension with gii.

add module file to the extension.

but my problem is every time I want test something, I have to commit,push,composer update to test it.

my goal is modules be installable by composer in production env but also easy to develop.

So whats the real problem? Your explanation aren’t clear as to what you are asking.

I do agree with Stefano’s asking.

I only understood as far as you CAN create a module.

As for the rest,

  1. Why are you doing all this for testing? First you make your module work in an application as a native module, only then test it’s installation on a clean system with composer. Why are you doing this every time?

  2. As for easiness of deployment, currently few modules can boast a zero configuration. Some of it needs to be done anyway. Are you talking about this?

What is the real problem?

I’m done #1.

I made native module.I’m able to change it to an extension and install it to clean system with composer also.

My real problem occurs when I want update module,I have to convert extension to native module again,do changes and test in dev env,then convert it to extension again.

because everything in vendor directory ignored by git.

I think my solution is git subtree like https://github.com/yiisoft/yii2/tree/master/extensions/mongodb and https://github.com/yiisoft/yii2-mongodb but there is no document for doing that

I think you need automate module => ext conversion, for which you need to write some shell or php script that should handle the routine tasks for you.

Then you should automate deployment to clean yii installation and check if it works.

Git subtree might help you to sync folders, but if there are other changes (i.e. modifying the code) i’d advise against it.

Also, I do not understand why can’t you develop your extension already in vendor directory, as it would be on any project? This should remove the need to convert module to extension and vice versa.

Why subtree? Just use development version of the package. Composer should get your module from repository so you have .git in your vendor/arash26/mymodule and can use git from the dir.

Excellent idea.

Thanks