### Development Setup and Testing Commands (Bash) Source: https://github.com/jbzoo/mermaid-php/blob/master/README.md A set of bash commands for managing the development environment of the jbzoo/mermaid-php project. These include installing dependencies, running unit tests, executing all tests and code quality checks, and performing code style checks using Makefiles. ```bash # Install dependencies make update ``` ```bash # Run tests make test ``` ```bash # Run all tests and code quality checks make test-all ``` ```bash # Run code style checks make codestyle ``` -------------------------------- ### Install/Update Dependencies (Bash) Source: https://github.com/jbzoo/mermaid-php/blob/master/CLAUDE.md Commands to manage project dependencies. 'make update' is the primary command, with 'composer update' serving as an alternative. These commands ensure all necessary libraries are installed or updated to their latest compatible versions. ```bash make update composer update ``` -------------------------------- ### Bash: Composer Installation for JBZoo/Mermaid-PHP Source: https://github.com/jbzoo/mermaid-php/blob/master/README.md This command installs the JBZoo/Mermaid-PHP library using Composer, the dependency manager for PHP. It assumes Composer is already installed on the system. ```bash composer require jbzoo/mermaid-php ``` -------------------------------- ### Get Raw Mermaid Syntax with JBZoo Mermaid PHP Source: https://github.com/jbzoo/mermaid-php/blob/master/README.md Retrieves the raw Mermaid syntax representation of a diagram generated by the JBZoo Mermaid PHP library. This allows for direct use of the Mermaid code in environments that support it. The syntax can be obtained by casting the diagram object to a string or using its `__toString()` method. This requires the JBZoo/MermaidPHP library. ```php // Get raw Mermaid syntax $mermaidCode = (string) $diagram; echo $diagram; // or use __toString() ``` -------------------------------- ### Get Live Editor URL for Mermaid Debugging (PHP) Source: https://github.com/jbzoo/mermaid-php/blob/master/README.md Retrieves a URL that points to the Mermaid live editor. This URL can be used for debugging or previewing the generated Mermaid diagram in an interactive online environment. It's a convenient way to quickly test and refine diagram syntax. ```php // Get URL to Mermaid live editor for debugging $url = $diagram->getLiveEditorUrl(); ``` -------------------------------- ### Generate and Upload Reports (Bash) Source: https://github.com/jbzoo/mermaid-php/blob/master/CLAUDE.md Commands for generating various reports and uploading test coverage. 'make report-all' creates comprehensive reports, while 'make report-coveralls' specifically uploads coverage data to Coveralls for tracking. ```bash make report-all make report-coveralls ``` -------------------------------- ### Run PHPUnit Tests (Bash) Source: https://github.com/jbzoo/mermaid-php/blob/master/CLAUDE.md Commands to execute automated tests using PHPUnit. 'make test' runs the standard test suite, while 'make test-all' includes additional code style checks. 'phpunit' can be used for direct execution. ```bash make test make test-all phpunit ``` -------------------------------- ### Fluent Interface for Graph Creation (PHP) Source: https://github.com/jbzoo/mermaid-php/blob/master/CLAUDE.md Demonstrates the fluent interface pattern used in the library for building diagrams. This allows for method chaining, making the code more readable and concise when adding nodes and links to a graph object. ```php $graph = (new Graph(['title' => 'My Graph'])) ->addNode($nodeA) ->addNode($nodeB) ->addLink(new Link($nodeA, $nodeB)); ``` -------------------------------- ### Code Quality Checks (Bash) Source: https://github.com/jbzoo/mermaid-php/blob/master/CLAUDE.md Command to perform comprehensive code quality checks, including linting and static analysis. Ensures code adheres to project standards and identifies potential issues before deployment. ```bash make codestyle ``` -------------------------------- ### PHP: Basic Flowchart Generation with JBZoo/Mermaid-PHP Source: https://github.com/jbzoo/mermaid-php/blob/master/README.md Demonstrates how to create a simple flowchart using the JBZoo/Mermaid-PHP library. It involves initializing a Graph object, adding nodes with different shapes, and defining links between them. The output can be Mermaid syntax, HTML with an embedded viewer, or a live editor URL. ```php 'My Workflow']); $graph ->addNode($start = new Node('start', 'Start', Node::ROUND)) ->addNode($process = new Node('process', 'Process Data', Node::SQUARE)) ->addNode($end = new Node('end', 'End', Node::ROUND)) ->addLink(new Link($start, $process)) ->addLink(new Link($process, $end)); // Output Mermaid syntax echo $graph; // Generate HTML with embedded viewer echo $graph->renderHtml(['theme' => 'dark']); // Get live editor URL for debugging echo $graph->getLiveEditorUrl(); ``` -------------------------------- ### Create Class Diagram with JBZoo Mermaid PHP Source: https://github.com/jbzoo/mermaid-php/blob/master/README.md Generates a UML class diagram with relationships, namespaces, and cardinality using the JBZoo Mermaid PHP library. This involves defining concepts (classes), attributes, methods, and relationships between them. The output can be rendered as HTML or Mermaid syntax, and a link to a live editor is provided. Requires the JBZoo/MermaidPHP library. ```php setTitle('Animal example') ->setDirection(\JBZoo\MermaidPHP\Direction::TOP_TO_BOTTOM) ->addClass($animalClass = new Concept( identifier: 'Animal', attributes: [ new Attribute('age', 'int', Visibility::PUBLIC), new Attribute('gender', 'String', Visibility::PUBLIC), ], annotation: 'abstract' )) ->addClass($duckClass = new Concept( identifier: 'Duck', attributes: [ new Attribute('beakColor', 'String', Visibility::PUBLIC), ], methods: [ new Method('swim') ], )) ->addRelationship(new Relationship( classA: $duckClass, classB: $animalClass, relationType: RelationType::REALIZATION )) ; //header('Content-Type: text/plain'); //echo $diagram; // Get result as string (or $diagram->__toString(), or (string) $diagram) $htmlCode = $diagram->renderHtml([ 'debug' => true, 'theme' => Render::THEME_DARK, 'title' => 'Example', 'show-zoom' => false, 'mermaid_url' => 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs', ]); // Get result as HTML code for debugging echo $diagram->getLiveEditorUrl(); // Get link to live editor ``` -------------------------------- ### Create Timeline Diagram with JBZoo Mermaid PHP Source: https://github.com/jbzoo/mermaid-php/blob/master/README.md Generates a timeline visualization using the JBZoo Mermaid PHP library. This involves creating a Timeline object, adding sections, markers, and events. The output can be rendered as HTML or a string representing the Mermaid syntax. Dependencies include the JBZoo/MermaidPHP library. ```php 'History of Social Media Platform'])) ->addSection( (new Timeline(['title' => 'Subsection 1'])) ->addMarker(new Marker('2002', [ new Event('Linkedin') ])) ) ->addSection( (new Timeline(['title' => 'Subsection 2'])) ->addMarker(new Marker('2004', [ new Event('Facebook'), new Event('Google'), ])) ->addMarker(new Marker('2005', [ new Event('Youtube'), ])) ->addMarker(new Marker('2006', [ new Event('Twitter'), ])) ) ; //header('Content-Type: text/plain'); //echo $diagram; // Get result as string (or $timeline->__toString(), or (string)$timeline) $htmlCode = $timeline->renderHtml([ 'debug' => true, 'theme' => Render::THEME_DARK, 'title' => 'Example', 'show-zoom' => false, 'mermaid_url' => 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs', ]); // Get result as HTML code for debugging echo $diagram->getLiveEditorUrl(); // Get link to live editor ``` -------------------------------- ### PHP: Advanced Flowchart and Subgraph Generation with JBZoo/Mermaid-PHP Source: https://github.com/jbzoo/mermaid-php/blob/master/README.md Illustrates the creation of more complex flowcharts using JBZoo/Mermaid-PHP, including subgraphs, custom styles, and links with special characters or HTML content. It showcases the library's flexibility in handling intricate diagram structures and diverse node/link configurations. ```php true])) ->addSubGraph($subGraph1 = new Graph(['title' => 'Main workflow'])) ->addSubGraph($subGraph2 = new Graph(['title' => 'Problematic workflow'])) ->addStyle('linkStyle default interpolate basis'); $subGraph1 ->addNode($nodeE = new Node('E', 'Result two', Node::SQUARE)) ->addNode($nodeB = new Node('B', 'Round edge', Node::ROUND)) ->addNode($nodeA = new Node('A', 'Hard edge', Node::SQUARE)) ->addNode($nodeC = new Node('C', 'Decision', Node::CIRCLE)) ->addNode($nodeD = new Node('D', 'Result one', Node::SQUARE)) ->addLink(new Link($nodeE, $nodeD)) ->addLink(new Link($nodeB, $nodeC)) ->addLink(new Link($nodeC, $nodeD, 'A double quote:"')) ->addLink(new Link($nodeC, $nodeE, 'A dec char:♥')) ->addLink(new Link($nodeA, $nodeB, ' Link text
/\\!@#$%^&*()_+><' " ')); $subGraph2 ->addNode($alone = new Node('alone', 'Alone')) ->addLink(new Link($alone, $nodeC)); echo $graph; // Get result as string (or $graph->__toString(), or (string)$graph) $htmlCode = $graph->renderHtml([ 'debug' => true, 'theme' => Render::THEME_DARK, 'title' => 'Example', 'show-zoom' => false, 'mermaid_url' => 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs', ]); // Get result as HTML code for debugging echo $graph->getLiveEditorUrl(); // Get link to live editor ``` -------------------------------- ### Render Mermaid Diagram to HTML with Viewer (PHP) Source: https://github.com/jbzoo/mermaid-php/blob/master/README.md Generates a complete HTML page that includes the Mermaid diagram and an embedded viewer for interactive rendering. This function accepts an array of options to customize the output, such as theme, title, zoom functionality, and the Mermaid CDN URL. It's useful for embedding diagrams directly into web pages. ```php // Generate complete HTML page with Mermaid viewer $htmlCode = $diagram->renderHtml([ 'theme' => Render::THEME_DARK, // dark, forest, default, neutral 'title' => 'My Diagram', 'show-zoom' => true, 'debug' => false, 'mermaid_url' => 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs' ]); ``` -------------------------------- ### Generate Mermaid ER Diagram in PHP Source: https://github.com/jbzoo/mermaid-php/blob/master/README.md This snippet shows how to construct an Entity-Relationship (ER) diagram using the JBZoo Mermaid PHP library. It involves defining entities with properties (including primary keys and types) and establishing relationships between them (e.g., OneToMany, ManyToOne). The library allows rendering the diagram as HTML or obtaining a link to the Mermaid live editor for visualization. ```php 'Order Example'])); $diagram ->addEntity($customerEntity = new Entity('C', 'Customer', props: [ new EntityProperty('id', 'int', [EntityProperty::PRIMARY_KEY], 'ID of user'), new EntityProperty('cash', 'float'), ])) ->addEntity($orderEntity = new Entity('O', 'Order')) ->addEntity($lineItemEntity = new Entity('LI', 'Line-Item')) ->addEntity($deliveryAddressEntity = new Entity('DA', 'Delivery-Address')) ->addEntity($creditCardEntity = new Entity('CC', 'Credit-Card')) ->addRelation(new OneToMany($customerEntity, $orderEntity, 'places', Relation::ONE_OR_MORE)) ->addRelation(new ManyToOne($lineItemEntity, $orderEntity, 'belongs', Relation::ZERO_OR_MORE)) ->addRelation(new ManyToMany($customerEntity, $deliveryAddressEntity, 'uses', Relation::ONE_OR_MORE)) ->addRelation(new OneToOne($customerEntity, $creditCardEntity, 'has', Relation::ONE_OR_MORE)) ; // Get result as HTML code for debugging $htmlCode = $diagram->renderHtml([ 'debug' => true, 'theme' => Render::THEME_DARK, 'title' => 'Example', 'show-zoom' => false, 'mermaid_url' => 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs', ]); // Get link to live editor echo $diagram->getLiveEditorUrl(); // The rendered ER diagram in Mermaid syntax (as shown in the input): // --- // title: Order Example // --- // erDiagram // "Customer" ||--|{ "Order" : places // "Line-Item" }o--|| "Order" : belongs // "Customer" }o--|{ "Delivery-Address" : uses // "Customer" ||--|| "Credit-Card" : has // "Customer" { // int id PK "ID of user" // float cash // } ``` -------------------------------- ### Generate Mermaid Flowchart in PHP Source: https://github.com/jbzoo/mermaid-php/blob/master/README.md This snippet demonstrates how to generate a Mermaid flowchart using the JBZoo Mermaid PHP library. It includes defining subgraphs, nodes with different shapes and edge types, and custom link text with special characters. The output can be rendered as HTML or a link to the Mermaid live editor. ```php B{Is it?
Yes};\n B --> C(End);\n A --> D{No};\n D --> C;"; // In a real scenario, you would use the library's classes to build this programmatically. // Example using the library (conceptual): // $graph = new JBZooMermaidPHPFlowchart(); // $graph->addNode('A', 'Start'); // $graph->addLink('A', 'B', 'Is it?', ['shape' => 'diamond', 'direction' => 'yes']); // ... and so on. // The provided example in the text uses raw Mermaid syntax: $rawMermaidCode = "graph TB;\n subgraph \"Main workflow\"\n E[\"Result two\"];\n B(Round edge);\n A[Hard edge];\n C((Decision));\n D[Result one];\n E-->D;\n B-->C;\n C-->|\"A double quote:#quot;\"|D;\n C-->|\"A dec char:#hearts;\"|E;\n A-->|\"Link text
/\\!@#$%^#amp;*()_+><' #quot;\"|B;\n end\n subgraph \"Problematic workflow\"\n alone(Alone);\n alone-->C;\n end\nlinkStyle default interpolate basis;"; // To get the HTML or live editor URL, you would typically instantiate a renderer: // $renderer = new Render(); // $html = $renderer->render($rawMermaidCode, ['type' => 'graph', 'theme' => 'forest']); // $liveEditorUrl = $renderer->getLiveEditorUrl($rawMermaidCode, ['type' => 'graph', 'theme' => 'forest']); // For this example, we'll just output the raw Mermaid code as it appears in the input. echo "---"; echo "title: Example Flowchart"; echo "---"; echo "```mermaid\n" . $rawMermaidCode . "\n```"; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.