Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel project UML Class diagram

Tags:

php

laravel-4

uml

I have been googling around for UML examples for MVC PHP Framework as well as a project UML Diagram to do with a PHP project but unfortunately java and c# examples always come up.

I have a small understanding of UML diagrams but not real example to see hwo it is used. I have a laravel project which I am working on and I want to create a UML class diagram to show the class i am using.

In java and PHP i know one of the ways to know if a class is associate with another is when it is getting instantiated in another class with the key word new

what I want to know is in laravel hwo do you know when a model or controller is associate with each other or another. I have asked in one of the community channels and someone told me "it is not really linked" which doesn't answer my question. What I want to know is if i do something like User::where('username', '=', $username)->where('active', '=', 0)->get(); in a controller does this mean that the controller is now associated with the User model or the controller is a dependency of the User model?

e.g.

enter image description here

What I am confusing about is another a UML class diagram will look like for any laravel or PHP MVC application.

Thanks

like image 466
Baako Avatar asked Nov 01 '22 07:11

Baako


1 Answers

You can show the relation between both by using a role name at each side of the association. The role name is placed "on the other side" of the association. So if AccountController uses User as currentUser then place the role name currentUser near the User attached association.

An example for the role use is this:

enter image description here

The class diagram will not tell you anything about instantiation itself. Rather you use a sequence diagram to show that. E.g. (without knowing anything about your domain) if AccountController creates a User object it will send a new message which tells that a :User instance has to be created. Termination can be shown by a X at the end of the life line of an object.

And the instances of these classes are used in a SD as follows:

enter image description here

The first message is the new message. The messages below use some of the operations you stated in your classes (no idea if that makes sense). The final X indicates the termination of :User

like image 119
qwerty_so Avatar answered Nov 09 '22 14:11

qwerty_so