F
F
Fyodor Dostoyevsky2014-09-26 09:52:05
Yii
Fyodor Dostoyevsky, 2014-09-26 09:52:05

How to develop a module in Yii2 and then easily connect it?

Hello. An urgent question has ripened for me.
I want to develop a module for Yii2, which can be easily connected to other projects in the future, say through composer. From here some questions:
1. How to organize migrations or import of necessary tables?
2. How to prevent table intersections in the database?
3. How to create a module that has both a backend and a frontend part?
4. How to do it most transparently for the developer who implements this product?
This question is more about working out the structure of such an application. It is necessary to form an ideal solution, well, or almost ideal)
For example, I want to develop a "news" module with my own database table structure. And I want a similar module to be installed through composer. Where should I look to get such a solution?
I hope for your support, friends.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Zelenin, 2014-09-26
@frops

1. How to arrange migrations or import of required tables?
standard. Put the migrations in module/migrations, in the readme specify the command for migration with --migrationPath
2. How to prevent table intersections in the database?
name tables like this

public function tableName()
{
return '{{%moduleName_tableName}}';
}

where moduleName is the name of your module
3. How can I create a module that has both a backend and a frontend part?
Holivary enough question. My opinion is that it is not necessary to split the controllers into two parts. It is necessary to break the necessary actions into different controllers by functionality, and the developer will already inherit these controllers in his project in the right places.
If you give a specific example, get a specific application.
4. How to do it most transparently for the developer who implements this product?
see point 3. Describe everything in the readme.

A
Alexander Litvinov, 2014-09-26
@Sander_Li

See how the extensions are arranged in the official repository
. Tables can be named with a certain prefix to prevent overlaps.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question