Wrap for PlantUml on PHP. Quick generating UML diagrams.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib Fix path Feb 20, 2015
LICENSE Initial commit Feb 12, 2015
README.md upd readme May 18, 2015
composer.json Composer fix 3 Feb 17, 2015

README.md

php-plantuml-wrap

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