jasir/php-plantuml-wrap

Wrap for UML generation by PlantUml on PHP, forked from sufir/php-plantuml-wrap

dev-master 2017-04-07 23:46 UTC

This package is not auto-updated.

Last update: 2020-02-21 17:20:19 UTC


README

Wrap for PlantUml on PHP. Quick generating UML diagrams.

Forked from https://github.com/Sufir/php-plantuml-wrap

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);

687474703a2f2f7777772e706c616e74756d6c2e636f6d3a38302f706c616e74756d6c2f706e672f685037444969443035384e74554f66424477765139696243396843485959386b3538484d4e447a43525a494f4a61656335426672394f427531687733584f4159784a44437469574f56705549585376594f3078564f53777a6e7278635065754c7061324e697462666f44494a55626147643175562d507774302d7855464a4774705072526b4d557454586c747744524774375146627055586b4e39526a75425874755f743547343631746262517a5a78353051303566303541616e796470434d3970414a64326a43624f704a41354f5950446570504b72477655534e445048504670773670673348303151735838497971653262314c4c4f47393452695877506a4145797444484b50515739316c6a4f38756f7239636b784e373757516e4b4250386738716157676475634762393079483236725f6b617a643476464562434b3271763170414c694d5361475653366232624363585550316d6a773741495a68506b6362706f5931324c4d426c46736144434e6f455f586c3752666a737a6f636c51795f6641545f7752316c364a336942774f46574435656a747962686d3030

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);

687474703a2f2f7777772e706c616e74756d6c2e636f6d3a38302f706c616e74756d6c2f706e672f684c4a54516a4c30344278464b6d703732777a774a4239394466356f65354a34326e4d6e35495f34597a6454734a4f7174504761684f6541415958596252773175316c4b736544372d6b436852447838464a624d4d7479384f6c54594f4d54646c6c6336787346676a546e694f384e6838436c725a54414751505151486d4e3164486c4e47792d783246517a5f54592d514e5669645a736d4f746a6139744f4378526c6b534a57446a325f69695473336b56795f74577941434259514c744b33596f5531304d3044576834696e38584f475a6e414f776275366c454f4977727137364853555150693241667950524d314b6c55644271314e3844343035644b3957687049473472524c363431484d77657a69596542696c424a4b454c4861616d6b3838446d65414b4c445354687570343544544e364b696d7176427649363657634357345861426671784e4e6266546c544b4c6e41645a36634f654c4b716459327635576f3241364365764f65614b7936774f57745374496374734e31326e486a504d7839674b66376c716168667375686c3771617765504f4c5f7743694643767161475369345a704c4d3046394b486e6534594155366e317431415a384b44624169717171306364326c6138477a4a644d5066753857655a3531687a35634f5833305f56714135676a37654243784462546d797836314b6f62576944384d2d5a62446f543939303841454b4b58646862456a564f507677565f4d59464e4f4546374274772d2d58422d56596e4a76484f5178564f37713943316d2d36564c67327653376a79647634474b4c6d2d356d75464b4d70447378654231514d776338704672486873525f334459644e67564c316f56426e45617169505f6a526c6c414a6a655469466c6b6b4d695f6a535f53564d5746732d7270715566436b7661587a667150336a6774525a726a6a6f2d58565576324f7a54727437724578445666706c4267747654565074733171697251525867724d3150625454514279363072522d5849434c7170656a5961514e76504151682d62326941312d4e532d6d7130