{"id":21823541,"url":"https://github.com/jbzoo/mermaid-php","last_synced_at":"2025-04-10T02:24:14.933Z","repository":{"id":36475938,"uuid":"227209511","full_name":"JBZoo/Mermaid-PHP","owner":"JBZoo","description":"Generate diagrams and flowcharts with the help of the mermaid script language","archived":false,"fork":false,"pushed_at":"2024-06-22T09:09:13.000Z","size":78,"stargazers_count":39,"open_issues_count":3,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T23:14:14.123Z","etag":null,"topics":["diagram","diagrams","flowchart","flowcharts","jbzoo","mermaid","mermaid-diagrams","mermaid-php","mermaidjs","php"],"latest_commit_sha":null,"homepage":"https://mermaidjs.github.io/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JBZoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-10T20:28:15.000Z","updated_at":"2024-12-05T20:14:00.000Z","dependencies_parsed_at":"2022-07-24T20:32:18.058Z","dependency_job_id":"9301ab1e-3872-4d6b-90fa-2446d753e5f1","html_url":"https://github.com/JBZoo/Mermaid-PHP","commit_stats":{"total_commits":50,"total_committers":4,"mean_commits":12.5,"dds":0.48,"last_synced_commit":"0b34a9ce6effbf304d1277a9864628bb2a00c624"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JBZoo%2FMermaid-PHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JBZoo%2FMermaid-PHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JBZoo%2FMermaid-PHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JBZoo%2FMermaid-PHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JBZoo","download_url":"https://codeload.github.com/JBZoo/Mermaid-PHP/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248143492,"owners_count":21054790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diagram","diagrams","flowchart","flowcharts","jbzoo","mermaid","mermaid-diagrams","mermaid-php","mermaidjs","php"],"created_at":"2024-11-27T17:33:17.583Z","updated_at":"2025-04-10T02:24:14.910Z","avatar_url":"https://github.com/JBZoo.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JBZoo / Mermaid-PHP\n\n[![CI](https://github.com/JBZoo/Mermaid-PHP/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/JBZoo/Mermaid-PHP/actions/workflows/main.yml?query=branch%3Amaster)    [![Coverage Status](https://coveralls.io/repos/github/JBZoo/Mermaid-PHP/badge.svg?branch=master)](https://coveralls.io/github/JBZoo/Mermaid-PHP?branch=master)    [![Psalm Coverage](https://shepherd.dev/github/JBZoo/Mermaid-PHP/coverage.svg)](https://shepherd.dev/github/JBZoo/Mermaid-PHP)    [![Psalm Level](https://shepherd.dev/github/JBZoo/Mermaid-PHP/level.svg)](https://shepherd.dev/github/JBZoo/Mermaid-PHP)    [![CodeFactor](https://www.codefactor.io/repository/github/jbzoo/mermaid-php/badge)](https://www.codefactor.io/repository/github/jbzoo/mermaid-php/issues)    \n[![Stable Version](https://poser.pugx.org/jbzoo/mermaid-php/version)](https://packagist.org/packages/jbzoo/mermaid-php/)    [![Total Downloads](https://poser.pugx.org/jbzoo/mermaid-php/downloads)](https://packagist.org/packages/jbzoo/mermaid-php/stats)    [![Dependents](https://poser.pugx.org/jbzoo/mermaid-php/dependents)](https://packagist.org/packages/jbzoo/mermaid-php/dependents?order_by=downloads)    [![GitHub License](https://img.shields.io/github/license/jbzoo/mermaid-php)](https://github.com/JBZoo/Mermaid-PHP/blob/master/LICENSE)\n\n\n\nGenerate diagrams and flowcharts as HTML which is based on [mermaid-js](https://mermaid.js.org/).\n\n\n### Usage\n\n```php\n\u003c?php\n\nuse JBZoo\\MermaidPHP\\Graph;\nuse JBZoo\\MermaidPHP\\Link;\nuse JBZoo\\MermaidPHP\\Node;\nuse JBZoo\\MermaidPHP\\Render;\n\n$graph = (new Graph(['abc_order' =\u003e true]))\n    -\u003eaddSubGraph($subGraph1 = new Graph(['title' =\u003e 'Main workflow']))\n    -\u003eaddSubGraph($subGraph2 = new Graph(['title' =\u003e 'Problematic workflow']))\n    -\u003eaddStyle('linkStyle default interpolate basis');\n\n$subGraph1\n    -\u003eaddNode($nodeE = new Node('E', 'Result two', Node::SQUARE))\n    -\u003eaddNode($nodeB = new Node('B', 'Round edge', Node::ROUND))\n    -\u003eaddNode($nodeA = new Node('A', 'Hard edge', Node::SQUARE))\n    -\u003eaddNode($nodeC = new Node('C', 'Decision', Node::CIRCLE))\n    -\u003eaddNode($nodeD = new Node('D', 'Result one', Node::SQUARE))\n    -\u003eaddLink(new Link($nodeE, $nodeD))\n    -\u003eaddLink(new Link($nodeB, $nodeC))\n    -\u003eaddLink(new Link($nodeC, $nodeD, 'A double quote:\"'))\n    -\u003eaddLink(new Link($nodeC, $nodeE, 'A dec char:♥'))\n    -\u003eaddLink(new Link($nodeA, $nodeB, ' Link text\u003cbr\u003e/\\\\!@#$%^\u0026*()_+\u003e\u003c\\' \" '));\n\n$subGraph2\n    -\u003eaddNode($alone = new Node('alone', 'Alone'))\n    -\u003eaddLink(new Link($alone, $nodeC));\n\necho $graph; // Get result as string (or $graph-\u003e__toString(), or (string)$graph)\n$htmlCode = $graph-\u003erenderHtml([\n    'debug'       =\u003e true,\n    'theme'       =\u003e Render::THEME_DARK,\n    'title'       =\u003e 'Example',\n    'show-zoom'   =\u003e false,\n    'mermaid_url' =\u003e 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs',\n]); // Get result as HTML code for debugging\n\necho $graph-\u003egetLiveEditorUrl(); // Get link to live editor\n```\n\n### Result\n[Open live editor](https://mermaid-js.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoiZ3JhcGggVEI7XG4gICAgc3ViZ3JhcGggXCJNYWluIHdvcmtmbG93XCJcbiAgICAgICAgRVtcIlJlc3VsdCB0d29cIl07XG4gICAgICAgIEIoXCJSb3VuZCBlZGdlXCIpO1xuICAgICAgICBBW1wiSGFyZCBlZGdlXCJdO1xuICAgICAgICBDKChcIkRlY2lzaW9uXCIpKTtcbiAgICAgICAgRFtcIlJlc3VsdCBvbmVcIl07XG4gICAgICAgIEUtLT5EO1xuICAgICAgICBCLS0+QztcbiAgICAgICAgQy0tPnxcIkEgZG91YmxlIHF1b3RlOiNxdW90O1wifEQ7XG4gICAgICAgIEMtLT58XCJBIGRlYyBjaGFyOiNoZWFydHM7XCJ8RTtcbiAgICAgICAgQS0tPnxcIkxpbmsgdGV4dDxicj5cL1xcIUAjJCVeI2FtcDsqKClfKz48JyAjcXVvdDtcInxCO1xuICAgIGVuZFxuICAgIHN1YmdyYXBoIFwiUHJvYmxlbWF0aWMgd29ya2Zsb3dcIlxuICAgICAgICBhbG9uZShcIkFsb25lXCIpO1xuICAgICAgICBhbG9uZS0tPkM7XG4gICAgZW5kXG5saW5rU3R5bGUgZGVmYXVsdCBpbnRlcnBvbGF0ZSBiYXNpczsiLCJtZXJtYWlkIjp7InRoZW1lIjoiZm9yZXN0In19)\n\n```\ngraph 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--\u003eD;\n        B--\u003eC;\n        C--\u003e|\"A double quote:#quot;\"|D;\n        C--\u003e|\"A dec char:#hearts;\"|E;\n        A--\u003e|\"Link text\u003cbr\u003e/\\!@#$%^#amp;*()_+\u003e\u003c' #quot;\"|B;\n    end\n    subgraph \"Problematic workflow\"\n        alone(\"Alone\");\n        alone--\u003eC;\n    end\nlinkStyle default interpolate basis;\n```\n\n\n### Usage of an ERDiagram\n\n```php\n\u003c?php\n\nuse JBZoo\\MermaidPHP\\ERDiagram\\Entity\\Entity;\nuse JBZoo\\MermaidPHP\\ERDiagram\\ERDiagram;\nuse JBZoo\\MermaidPHP\\ERDiagram\\Relation\\ManyToMany;\nuse JBZoo\\MermaidPHP\\ERDiagram\\Relation\\ManyToOne;\nuse JBZoo\\MermaidPHP\\ERDiagram\\Relation\\OneToMany;\nuse JBZoo\\MermaidPHP\\ERDiagram\\Relation\\OneToOne;\nuse JBZoo\\MermaidPHP\\ERDiagram\\Relation\\Relation;\nuse JBZoo\\MermaidPHP\\Render;\n\n$diagram = (new ERDiagram(['title' =\u003e 'Order Example']));\n\n$diagram\n    -\u003eaddEntity($customerEntity = new Entity('C', 'Customer', props: [\n        new EntityProperty('id', 'int', [EntityProperty::PRIMARY_KEY], 'ID of user'),\n        new EntityProperty('cash', 'float'),\n    ]))\n    -\u003eaddEntity($orderEntity = new Entity('O', 'Order'))\n    -\u003eaddEntity($lineItemEntity = new Entity('LI', 'Line-Item'))\n    -\u003eaddEntity($deliveryAddressEntity = new Entity('DA', 'Delivery-Address'))\n    -\u003eaddEntity($creditCardEntity = new Entity('CC', 'Credit-Card'))\n    -\u003eaddRelation(new OneToMany($customerEntity, $orderEntity, 'places', Relation::ONE_OR_MORE))\n    -\u003eaddRelation(new ManyToOne($lineItemEntity, $orderEntity, 'belongs', Relation::ZERO_OR_MORE))\n    -\u003eaddRelation(new ManyToMany($customerEntity, $deliveryAddressEntity, 'uses', Relation::ONE_OR_MORE))\n    -\u003eaddRelation(new OneToOne($customerEntity, $creditCardEntity, 'has', Relation::ONE_OR_MORE))\n;\n//header('Content-Type: text/plain');\n//echo $diagram; // Get result as string (or $graph-\u003e__toString(), or (string)$graph)\n$htmlCode = $diagram-\u003erenderHtml([\n    'debug'       =\u003e true,\n    'theme'       =\u003e Render::THEME_DARK,\n    'title'       =\u003e 'Example',\n    'show-zoom'   =\u003e false,\n    'mermaid_url' =\u003e 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs',\n]); // Get result as HTML code for debugging\n\necho $diagram-\u003egetLiveEditorUrl(); // Get link to live editor\n```\n\n### Result\n[Open live editor](https://mermaid-js.github.io/mermaid-live-editor/edit#pako:eNp1kE1qxDAMha9itB5fILuSdDG00EK33qixMjH4J9hK6ZDk7qM4U0phqpV4-vSe0AJ9sgQNaK1NZMeeGvWWLWX1_I1h8mRiHVHuHF4yBhOVlIF2LpwCZQNqXbVeF9HqogiNmjz2VH7YVxdJn5mCzLYk8PoH_iSf4qU8cK7w7tyRd1-Ur_rJ2kyl1L25UPnvnD2hzWQd6xazrfyIj_Dl0PZykZWz6v1FiHOn0rBHCPNLDD4hqx7LeGibiXACMQrorLyxmhngkQIZaKQdktzLu8cmJM6cPq6xh4bzTCeYJ4tM99ce4nYDIeuBCQ)\n\n```\n---\ntitle: Order Example\n---\nerDiagram\n    \"Customer\" ||--|{ \"Order\" : places\n    \"Line-Item\" }o--|| \"Order\" : belongs\n    \"Customer\" }o--|{ \"Delivery-Address\" : uses\n    \"Customer\" ||--|| \"Credit-Card\" : has\n    \"Customer\" {\n        int id PK \"ID of user\"\n        float cash\n    }\n```\n\n\n### Usage of an Timeline\n\n```php\n\u003c?php\n\nuse JBZoo\\MermaidPHP\\Timeline\\Timeline;\nuse JBZoo\\MermaidPHP\\Timeline\\Marker;\nuse JBZoo\\MermaidPHP\\Timeline\\Event;\n\n$timeline = (new Timeline(['title' =\u003e 'History of Social Media Platform']))\n    -\u003eaddSection(\n        (new Timeline(['title' =\u003e 'Subsection 1']))\n            -\u003eaddMarker(new Marker('2002', [\n                new Event('Linkedin')\n            ]))\n    )\n    -\u003eaddSection(\n        (new Timeline(['title' =\u003e 'Subsection 2']))\n            -\u003eaddMarker(new Marker('2004', [\n                new Event('Facebook'),\n                new Event('Google'),\n            ]))\n            -\u003eaddMarker(new Marker('2005', [\n                new Event('Youtube'),\n            ]))\n            -\u003eaddMarker(new Marker('2006', [\n                new Event('Twitter'),\n            ]))\n    )\n;\n//header('Content-Type: text/plain');\n//echo $diagram; // Get result as string (or $timeline-\u003e__toString(), or (string)$timeline)\n$htmlCode = $timeline-\u003erenderHtml([\n    'debug'       =\u003e true,\n    'theme'       =\u003e Render::THEME_DARK,\n    'title'       =\u003e 'Example',\n    'show-zoom'   =\u003e false,\n    'mermaid_url' =\u003e 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs',\n]); // Get result as HTML code for debugging\n\necho $diagram-\u003egetLiveEditorUrl(); // Get link to live editor\n```\n\n### Result\n[Open live editor](https://mermaid-js.github.io/mermaid-live-editor/#/edit/eyJjb2RlIjoidGltZWxpbmVcbiAgICB0aXRsZSBIaXN0b3J5IG9mIFNvY2lhbCBNZWRpYSBQbGF0Zm9ybVxuICAgIHNlY3Rpb24gXCJTdWJzZWN0aW9uIDFcIlxuICAgICAgICAyMDAyIDogTGlua2VkaW5cbiAgICBzZWN0aW9uIFwiU3Vic2VjdGlvbiAyXCJcbiAgICAgICAgMjAwNCA6IEZhY2Vib29rIDogR29vZ2xlXG4gICAgICAgIDIwMDUgOiBZb3V0dWJlXG4gICAgICAgIDIwMDYgOiBUd2l0dGVyXG4iLCJtZXJtYWlkIjp7InRoZW1lIjoiZm9yZXN0In19)\n\n```\ntimeline\n    title History of Social Media Platform\n    section \"Subsection 1\"\n        2002 : Linkedin\n    section \"Subsection 2\"\n        2004 : Facebook : Google\n        2005 : Youtube\n        2006 : Twitter\n\n```\n\n### Usage of a Class Diagram\n\n```php\n\u003c?php\n\nuse JBZoo\\MermaidPHP\\ClassDiagram\\ClassDiagram;\nuse JBZoo\\MermaidPHP\\ClassDiagram\\Concept\\Concept;\nuse JBZoo\\MermaidPHP\\ClassDiagram\\Concept\\Attribute;\nuse JBZoo\\MermaidPHP\\ClassDiagram\\Concept\\Visibility;\nuse JBZoo\\MermaidPHP\\ClassDiagram\\Concept\\Method;\nuse JBZoo\\MermaidPHP\\ClassDiagram\\Relationship\\Relationship;\nuse JBZoo\\MermaidPHP\\ClassDiagram\\Relationship\\RelationType;\nuse JBZoo\\MermaidPHP\\Render;\n\n$diagram = (new ClassDiagram())\n    -\u003esetTitle('Animal example')\n    -\u003esetDirection(\\JBZoo\\MermaidPHP\\Direction::TOP_TO_BOTTOM)\n    -\u003eaddClass($animalClass = new Concept(\n        identifier: 'Animal',\n        attributes: [\n            new Attribute('age', 'int', Visibility::PUBLIC),\n            new Attribute('gender', 'String', Visibility::PUBLIC),\n        ],\n        annotation: 'abstract'\n    ))\n    -\u003eaddClass($duckClass = new Concept(\n        identifier: 'Duck',\n        attributes: [\n            new Attribute('beakColor', 'String', Visibility::PUBLIC),\n        ],\n        methods: [\n            new Method('swim')\n        ],\n    ))\n    -\u003eaddRelationship(new Relationship(\n        classA: $duckClass,\n        classB: $animalClass,\n        relationType: RelationType::REALIZATION\n    ))\n;\n//header('Content-Type: text/plain');\n//echo $diagram; // Get result as string (or $diagram-\u003e__toString(), or (string) $diagram)\n$htmlCode = $diagram-\u003erenderHtml([\n    'debug'       =\u003e true,\n    'theme'       =\u003e Render::THEME_DARK,\n    'title'       =\u003e 'Example',\n    'show-zoom'   =\u003e false,\n    'mermaid_url' =\u003e 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs',\n]); // Get result as HTML code for debugging\n\necho $diagram-\u003egetLiveEditorUrl(); // Get link to live editor\n```\n\n### Result\n[Open live editor](https://mermaid-js.github.io/mermaid-live-editor/edit#pako:eNo1kMFugzAMhl8l8mnTEIIS0IoqpG297tSdplzcxGVRSVKFoK1jvPtSCr7E_vz7T-IRpFMENcgO-36vsfVohFXakwzaWfbxKuzcYy9WG-zYKCyLsdvhsQ8eZWiaO3nSNjBsaakOwWvbspasIi_stNrsB3leTVbRkfD85jrn77j_1ubhcZ6Z1Wn61yzXCwsJGPIGtYqvnn0EhC8yJKCO6cl56oOAOB2VOAR3uFoJdfADJTBcFAZavgn1Cbs-0gvaT-fMKool1CP8QJ1znj7zbV5URbkpi21WJXCNOCtTzivO86rMbnQzJfA7O2RpmQApHZx_XxZ7O6Z_kFxzOQ)\n\n```\n---\ntitle: Animal example\n---\nclassDiagram\ndirection TB\nclass Animal {\n    \u003c\u003cabstract\u003e\u003e\n    +int age\n    +String gender\n}\nclass Duck {\n    +String beakColor\n    swim()\n}\nDuck ..|\u003e Animal\n```\n\n### See also\n - [Mermaid on GitHub](https://github.com/mermaid-js/mermaid)\n - [Mermaid Documentation](https://mermaid.js.org/)\n\n\n## Unit tests and check code style\n```sh\nmake update\nmake test-all\n```\n\n\n## License\n\nMIT\n\n\n## See Also\n\n- [CI-Report-Converter](https://github.com/JBZoo/CI-Report-Converter) - Converting different error reports for deep compatibility with popular CI systems.\n- [Composer-Diff](https://github.com/JBZoo/Composer-Diff) - See what packages have changed after `composer update`.\n- [Composer-Graph](https://github.com/JBZoo/Composer-Graph) - Dependency graph visualization of composer.json based on mermaid-js.\n- [Utils](https://github.com/JBZoo/Utils) - Collection of useful PHP functions, mini-classes, and snippets for every day.\n- [Image](https://github.com/JBZoo/Image) - Package provides object-oriented way to manipulate with images as simple as possible.\n- [Data](https://github.com/JBZoo/Data) - Extended implementation of ArrayObject. Use files as config/array.\n- [Retry](https://github.com/JBZoo/Retry) - Tiny PHP library providing retry/backoff functionality with multiple backoff strategies and jitter support.\n- [SimpleTypes](https://github.com/JBZoo/SimpleTypes) - Converting any values and measures - money, weight, exchange rates, length, ...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbzoo%2Fmermaid-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbzoo%2Fmermaid-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbzoo%2Fmermaid-php/lists"}