Design a yii2 app in an object oriented way

Hello guys,

I have already built a yii2 app using what is usually used: data processing. I Just created my database and used gii to generate Models. The actions of my unique controller was the fonctionalities that user can access: login, logout…

Now i want to built another app and wanna do it in the best way using my class diagram… That appli is bigger than the prévious and will grow up by time.

Please can anyone tell me how to process? where should i put my classes? Are they all models? what will be my controller? My actions?

I am waiting.

thanks.

Hi,

Have you already read the complete guide here?

http://www.yiiframework.com/doc-2.0/guide-README.html

It will probably answer all your questions.

Best Regards

Yes i read the yii2 guide before implémenting my last yii2 app. I’m still reading it but for advanced concepts.

Know i want to use a better conception way: OO. My problem is: after app conception should i create new classes and models with methods. Or should i have only Model classes eventually with controllers…? I wanted to create classes that are not models. Is it a good idea?

I Know theorically how the MVC pattern works and how yii2 uses it. But i don’t Know how to match my conception results(classes…) with the mvc parts.

My app is a kind of social network and fonctionalities will be add continuously. It is important that it is best design.

Thank you So much for paying attention to my préoccupation.

A Model is a class.

It is often best practice to make fat models and skinny controllers.

Don’t over-think your application ;)

Use ZEND-like modules. In Yii2 you can write app using modules. Each module has it own models, components, controllers, views etc. Modules make project more maintainable and extendible.

Thanks.

Could you please help me to divide a standard social network into modules?

I will add more methods to my Model classes. But for controllers i don’t really nkow when to create a new one.

You know when you need actions - read the friendly manual (Yii Guide) :)

For example:

User/

Registration -> models, controllers, views

User profile -> models, controllers, views

Messages -> models, controllers, views

Wall -> models, controllers, views

Photos -> models, controllers, views

Relations -> models, controllers, views

etc…

Admin/

User data edition

Settings

Newsletter, mailer

3rd plugins

etc…

common/ models, layouts, components

Have a look at HumHub - Social Network Kit: