sufir / php-plantuml-wrap
Wrap for UML generation by PlantUml on PHP
dev-master
2015-05-18 08:40 UTC
Requires
- php: >= 5.3
This package is not auto-updated.
Last update: 2024-11-09 18:16:54 UTC
README
Wrap for PlantUml on PHP. Quick generating UML diagrams.
Installing with composer
"require": {
"sufir/php-plantuml-wrap": "dev-master"
},
Example 1
$plantuml = new PlantUml(); // Create new component diagram $diagram = $plantuml->createDiagram('component') ->setUmlNotation(Component::NOTATION_UML1); // Create diagram elements $firstComponent = $plantuml->createElement('component', 'component', 'First Component') ->setNote("A note can also be\non several lines", 'right'); $da = $plantuml->createElement('component', 'interface', 'Data Access'); $http = $plantuml->createElement('component', 'interface', 'HTTP') ->setNote("Web Service only"); // Create relations $rel1 = $plantuml->createRelation($firstComponent, $da) ->setDirection(Relation::DIRECTION_LEFT); $rel2 = $plantuml->createRelation() ->setFrom($firstComponent) ->setTo($http, Relation::ARROW_ASSOCIATION) ->setDirection(Relation::DIRECTION_BOTTOM) ->setLineType(Relation::LINE_DOTTED); // Assembly diagram $diagram->addElement($firstComponent) ->addElement($da) ->addElement($http) ->addRelation($rel1) ->addRelation($rel2); // Render diagram echo $plantuml->convertDiagram($diagram);
Example 2
$plantuml = new PlantUml(); // Create new component diagram $diagram = $plantuml->createDiagram('component') ->setUmlNotation(Component::NOTATION_UML2); // Style for webservers $webserverSkin = $plantuml->createSkin() ->setBackgroundGradient('white', 'lightblue') ->setBorderColor('black'); // Create elements stereotype https://en.wikipedia.org/wiki/Stereotype_(UML) $webserverStereotype = $plantuml->createStereotype('Web Server') ->setSkin($webserverSkin); // Create diagram elements $firstComponent = $plantuml->createElement('component', 'component', 'First Component') ->setNote("A note can also be\non several lines", 'right'); $da = $plantuml->createElement('component', 'interface', 'Data Access'); $http = $plantuml->createElement('component', 'interface', 'HTTP') ->setNote("Web Service only"); $webserver1 = $plantuml->createElement('component', 'component', 'Apache') ->addStereotype($webserverStereotype); $webserver2 = $plantuml->createElement('component', 'component', 'Nginx') ->addStereotype($webserverStereotype); // Grouping components $webserversGroup = $plantuml->createElement('component', 'frame', 'Servers') ->addElement($webserver1) ->addElement($webserver2); // Create relations $rel1 = $plantuml->createRelation($firstComponent, $da) ->setDirection(Relation::DIRECTION_LEFT); $rel2 = $plantuml->createRelation() ->setFrom($firstComponent) ->setTo($http, Relation::ARROW_EXTENSION) ->setLabel('Rel label...') ->setDirection(Relation::DIRECTION_BOTTOM) ->setLineType(Relation::LINE_DOTTED); $rel3 = $plantuml->createRelation() ->setFrom($http) ->setTo($webserver1, Relation::ARROW_ASSOCIATION) ->setDirection(Relation::DIRECTION_RIGHT) ->setColor('darkgreen'); $rel4 = $plantuml->createRelation() ->setFrom($http) ->setTo($webserver2, Relation::ARROW_ASSOCIATION) ->setDirection(Relation::DIRECTION_RIGHT) ->setColor('darkgreen'); // Assembly diagram $diagram->addElement($firstComponent) ->addElement($da) ->addElement($http) ->addElement($webserversGroup) ->addRelation($rel1) ->addRelation($rel2) ->addRelation($rel3) ->addRelation($rel4); // Render diagram echo $plantuml->convertDiagram($diagram);