Skip to content

Instantly share code, notes, and snippets.

@kgust
Last active August 29, 2018 20:18
Show Gist options
  • Save kgust/c59b85d246661f0e2e5a227c1bc08c79 to your computer and use it in GitHub Desktop.
Save kgust/c59b85d246661f0e2e5a227c1bc08c79 to your computer and use it in GitHub Desktop.
All Things PlantUML

This is the best resource for PlantUML details.

Important Points

When you add the PlantUML plugin to PHPStorm, it creates a number of UML* template files that are examples that you can edit.

PlantUML can be generated by programs. E.g. php-plantumlwriter) It's even simple enough that we can write our own programs to generate PlantUML for our own use.

If you'd like to create PlantUML using PHP:

Additional Points

  1. PlantUML is written in Java
  • java -jar plantuml.jar <options> <files>
  • It can produce SVG, PNG, and LaTeX files. Plus a lot more.
  • It can even produce ASCII art (for sequence diagrams)
  1. PlantUML can be styled using skinparam and other attributes...
  • E.g. skinparam componentStyle uml2
  1. PlantUML is only text, so it can...
  • Be embedded into any file (e.g. comments)
  • Be generated by programs
  1. Other Resources
@startuml
title Sequence Diagram
left header Howdy Y'all
actor Bugs
actor Fudd
Bugs -> Fudd : hey, what's up doc?
Fudd --> Bugs : Shh, be vewy, vewy, quiet...\nI'm hunting wabbits!
center footer That's all folks!
@enduml
@startuml
actor Jerry order 10
participant "DISCOVR-e" as dsc order 20
participant LDAP order 30
database Oracle as DB order 40
Jerry -> dsc : login
group Auth
dsc -> LDAP: authenticate
activate LDAP
LDAP --> dsc : user is valid
deactivate LDAP
end
group Oracle
dsc -> DB : fetch user
DB -> DB : Where did I put that?\nOh yeah!
DB --> dsc: user details
end
dsc --> Jerry : dashboard
@enduml
@startuml
start
:Jerry sends login request;
:DISCOVR-e sends auth request;
if (valid user/pass?) then (yes)
:DISCOVR-e fetches\nuser info from DB;
:DISCOVR-e returns\nthe Dashboard page;
else (no)
:DISCOVR-e returns a\nfailure message;
endif
stop
@enduml
@startuml
start
repeat
:read data;
:generate diagrams|
repeat while (more data?)
stop
@enduml
@startuml
|#eee|IRB|
start
:initialize;
:open connection;
:push data;
|#ccc|eSMART|
:process data;
:send response code;
|IRB|
:record transaction;
:close connection;
stop
@enduml
@startuml
set namespaceSeparator \\
namespace IRB\DefaultBundle\Entities {
class "User" {
- int id
- string name
- int roleId
..Getters..
+ string getName()
+ array getRoles()
..Setters..
+ string setName(string $name)
+ array addRole(Role $role)
}
class Role {
+ int id
# string name
- updated_at
}
User <|-- Role
}
@enduml
@startuml
scale 600 width
[*] -> State1
State1 --> State2 : Succeeded
State1 --> [*] : Aborted
State2 --> State3 : Succeeded
State2 --> [*] : Aborted
state State3 {
state "Accumulate Enough Data\nLong State Name" as long1
long1 : Just a test
[*] --> long1
long1 --> long1 : New Data
long1 --> ProcessData : Enough Data
}
State3 --> State3 : Failed
State3 --> [*] : Succeeded / Save Result
State3 --> [*] : Aborted
@enduml
@startuml
robust "Web Browser" as WB
concise "Web User" as WU
@0
Title My Timing Diagram
header: my header
footer: my footer
legend
Some legend
end legend
caption my caption
@0
WU is Idle
WB is Idle
@100
WU is Waiting
WB is Processing
@300
WB is Waiting
@enduml
@startsalt
{
Just plain text
[This is my button]
() Unchecked radio
(X) Checked radio
[] Unchecked box
[X] Checked box
"Enter text here "
^This is a droplist^
}
@endsalt
@startditaa
+--------+ +-------+ +-------+
| +---+ ditaa +-->| |
| Text | +!magic!+ |diagram|
|Document| | | | |
| {d}| | | | |
+---+----+ +-------+ +-------+
: ^
| Lots of work |
+------------------------+
+------+
|Oracle|
| {s} |
|VUMCIT|
+------+
@endditaa
┌─┐ ,.-^^-._
║"│ |-.____.-|
└┬┘ | |
┌┼┐ | |
│ ┌─────────┐ ┌────┐ | |
┌┴┐ │DISCOVR-e│ │LDAP│ '-.____.-'
Jerry └────┬────┘ └─┬──┘ Oracle
│ login │ │ │
│─────────────────>│ │ │
│ │ │ │
│ │ │ │
│ ╔═══════╤══════╪═════════════════╪════════════╗ │
│ ║ AUTH │ │ │ ║ │
│ ╟───────┘ │ authenticate ┌┴┐ ║ │
│ ║ │───────────────>│ │ ║ │
│ ║ │ │ │ ║ │
│ ║ │ user is valid │ │ ║ │
│ ║ │<─ ─ ─ ─ ─ ─ ─ ─│ │ ║ │
│ ╚══════════════╪══════════════════════════════╝ │
│ │ │ │
│ │ │ │
│ ╔═════════╤════╪═════════════════╪════════════════╪═══════════════════════════════╗
│ ║ ORACLE │ │ │ │ ║
│ ╟─────────┘ │ fetch user │ ║
│ ║ │─────────────────────────────────>│ ║
│ ║ │ │ │ ║
│ ║ │ │ │────┐ ║
│ ║ │ │ │ │ Where did I put that? ║
│ ║ │ │ │<───┘ Oh yeah! ║
│ ║ │ │ │ ║
│ ║ │ │ │ ║
│ ║ │ user details │ ║
│ ║ │<─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│ ║
│ ╚══════════════╪═════════════════╪════════════════╪═══════════════════════════════╝
│ │ │ │
│ dashboard │ │ │
│<─ ─ ─ ─ ─ ─ ─ ─ ─│ │ │
Jerry ┌────┴────┐ ┌─┴──┐ Oracle
┌─┐ │DISCOVR-e│ │LDAP│ ,.-^^-._
║"│ └─────────┘ └────┘ |-.____.-|
└┬┘ | |
┌┼┐ | |
│ | |
┌┴┐ '-.____.-'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment