Generate a class diagram
The phuml:diagram command will generate a class diagram by scanning the code from a given directory.
It has the following arguments:
directory. The directory with the code to be scanned to generate the class diagramoutput. The file name for yourpngclass diagram
It has the following options:
processor(-p). It will let you choose betweenneatoanddotto generate the class diagramassociations(-a). If present, the command will generate association among classes. It will extract them from the types of the attributes of the class. It will also use the types from the arguments passed to the constructorrecursive(-r). If present, it will scan the givendirectoryrecursivelyhide-private(-i). If present, it will exclude private methods, attributes, and constantshide-protected(-o). If present, it will exclude protected methods, attributes and constantshide-attributes(-t). If present, it will exclude all the attributeshide-methods(-m). If present, it will exclude all the methodshide-empty-blocks(-b). If present, no empty blocks will be showntheme(-e). Colors and fonts to be used for the diagram. There are 3 themes to choose from:phuml, which is the default theme,php, andclassic
Examples
- The following command will produce a class diagram from the
srcdirectory. - The diagram will be saved to the file
example.pngin the current directory. - It will search for classes and interfaces recursively, because of the
-roption. - It will generate associations (
-a), by inspecting attributes and constructor parameters in all the classes. - It will use the
dotcommand to generate the diagram, because of the-p dotoption. - It will only show public methods and attributes because both options
-iand-oare present
# Composer installation
vendor/bin/phuml phuml:diagram -r -a -i -o -p dot src example.png
# Docker installation
docker run --rm -v $PWD:/code montealegreluis/phuml phuml:diagram -r -a -i -o -p dot src example.png
# Phive installation
tools/phuml phuml:diagram -r -a -i -o -p dot src example.png
- The following command will produce a class diagram from the
srcdirectory. - The diagram will be saved to the file
example.pngin the current directory. - It will search for classes and interfaces recursively, because of the
-roption. - It will use the
dotcommand to generate the diagram, because of the-p dotoption. - It will only show names because both options
-tand-mare present. - Option
-ais not present since there are no attributes nor constructors to look for associations.
# Composer installation
vendor/bin/phuml phuml:diagram -r -t -m -p dot src example.png
# Docker installation
docker run --rm -v $PWD:/code montealegreluis/phuml phuml:diagram -r -t -m -p dot src example.png
# Phive installation
tools/phuml phuml:diagram -r -t -m -p dot src example.png
- The following command will produce a class diagram from the
srcdirectory. - The diagram will be saved to the file
example.pngin the current directory. - It will search for classes and interfaces recursively, because of the
-roption. - It will use the
dotcommand to generate the diagram, because of the-p dotoption. - It will only show names because both options
-tand-mare present. - Option
-ais not present since there are no attributes nor constructors to look for associations. - It will not create rows for methods and attributes because of the
-boption.
# Composer installation
vendor/bin/phuml phuml:diagram -r -t -m -b -p dot src example.png
# Docker installation
docker run --rm -v $PWD:/code montealegreluis/phuml phuml:diagram -r -t -m -b -p dot src example.png
# Phive installation
tools/phuml phuml:diagram -r -t -m -b -p dot src example.png
- The following command will produce a class diagram from the
srcdirectory. - The diagram will be saved to the file
example.pngin the current directory. - It WILL NOT search for classes and interfaces recursively, because of the lack of the
-roption. - It WILL NOT generate associations because of the lack of the
-aoption. - It will use the
neatocommand to generate the diagram, because of the-p neatooption. - It will show all methods and attributes because both options
-iand-oare absent
# Composer installation
vendor/bin/phuml phuml:diagram -p neato src example.png
# Docker installation
docker run --rm -v $PWD:/code montealegreluis/phuml phuml:diagram -p neato src example.png
# Phive installation
tools/phuml phuml:diagram -p neato src example.png
- The following command will produce a class diagram from the
srcdirectory. - The diagram will be saved to the file
example.pngin the current directory. - It WILL NOT search for classes and interfaces recursively, because of the lack of the
-roption. - It WILL NOT generate associations because of the lack of the
-aoption. - It will use the
dotcommand to generate the diagram, because of the-p dotoption. - It will show all methods and attributes because both options
-iand-oare absent - It will use colors purple and white because the option
eis thephptheme
# Composer installation
vendor/bin/phuml phuml:diagram -p dot -e php src example.png
# Docker installation
docker run --rm -v $PWD:/code montealegreluis/phuml phuml:diagram -p dot -e php src example.png
# Phive installation
tools/phuml phuml:diagram -p dot -e php src example.png