Download the PHP package bound1ess/mermaid-php without Composer
On this page you can find all versions of the php package bound1ess/mermaid-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bound1ess/mermaid-php
More information about bound1ess/mermaid-php
Files in bound1ess/mermaid-php
Package mermaid-php
Short Description PHP adapter for the Mermaid project by @knsv (github.com/knsv/mermaid).
License MIT
Informations about the package mermaid-php
MermaidPhp
First, make yourself familiar with the brilliant Mermaid project.
Basically, MermaidPhp provides you a nice and clean interface to generate compatible with Mermaid code.
Now (if you want to give it a try), lets review the installation process.
Installation
In order to install MermaidPhp, you need Composer.
Run the following command in your project root directory:
Ok, now include vendor/autoload.php file in your project (if you have not done this yet)
and you are all set to go!
Example of usage
This PHP code:
Will produce something like this:

If you want to see this example in your browser, do the following:
- Execute
vendor/bound1ess/php-mermaid/examples/createfile, it will produceexample.htmlfile in your project root directory. - Now set up a PHP development server by running this command:
php -S localhost:8000. - View the
example.htmlfile in your browser by visitinglocalhost:8000/example.html.
API
-
Bound1ess\MermaidPhp\Printer__construct($testMode = false)$testMode: when set totrue,Printerwill produce code that is invalid, but much easier to test.
printGraph(Graph $graph, $wrapInDiv = false)$graph: an instance ofBound1ess\MermaidPhp\Graphis expected.$wrapInDiv: when set totrue, the code produced will be wrapped in a<div>element with the classmermaid.- This method will return a string.
-
Bound1ess\MermaidPhp\Graph__construct($direction = null)$direction: if notnull,setDirectionmethod will be called.
setDirection($direction)$direction: valid values areNode::TOP_BOTTOM,Node::BOTTOM_TOP,Node::LEFT_RIGHT,Node::RIGHT_LEFT,from top to bottom,from bottom to top,from left to right,from right to left.- This method will return nothing (void).
- This method can throw an instance of
Bound1ess\MermaidPhp\Exceptions\InvalidDirectionException.
addNode(Node $node)$node: an instance ofBound1ess\MermaidPhp\Nodeis expected.- This method will return nothing (void).
addNodes(Node $node, ...)addLink(Link $link)$link: an instance ofBound1ess\MermaidPhp\Linkis expected.- This method will return nothing (void).
addLinks(Link $link, ...)addClass(NodeClass $class)$class: an instance ofBound1ess\MermaidPhp\NodeClass.- This method will return nothing (void).
addClassesdynamic: as manyBound1ess\MermaidPhp\NodeClassinstances as you need.- This method will return nothing (void).
-
Bound1ess\MermaidPhp\Node__construct($id, array $settings = null)$id: the node id (should be a string).$settings: if notnull,setTextmethod will be called.
setText($text, $style = null)$text: the node text (should be a string).$style: valid values areNode::ROUND_EDGE,Node::SQUARE_EDGE,Node::CIRCLE,Node::RHOMBUS,Node::ASYMETRIC_SHAPE. Ifnullis passed,Node::SQUARE_EDGEwill be used.- This method can throw an instance of
Bound1ess\MermaidPhp\Exceptions\InvalidStyleException. - This method will return nothing (void).
attachClass($name)$name: the class name as astring.- This method will return nothing (void).
attachClassesdynamic: as manystrings as you need.- This method will return nothing (void).
-
Bound1ess\MermaidPhp\Link__construct(Node $node, Node $anotherNode, $text = null, $isOpen = false)$node: an instance ofBound1ess\MermaidPhp\Nodeis expected.$anotherNode: an instance ofBound1ess\MermaidPhp\Nodeis expected.$text: the text on link (should be a string ornull).$isOpen: whether the link should be open or with arrow head (should be a boolean, the default value isfalse).
setText($text)$text: the text on link (should be a string).- This method will return nothing (void).
isOpen($newValue = null)$newValue: ifnullis passed, this method will return the current value, otherwise new value will be set (should be a boolean value).- This method will return a boolean value or nothing (void).
Bound1ess\MermaidPhp\NodeClass__construct($name)$name: the class name as astring.
add($property, $value)$property: the property name as astring.$value: the property value as astring.- This method will return the class instance itself.
License information
This project is licensed under the MIT license (see the license file for detailed information).