Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tasuku43/php-mermaid-class-diagram
Generate Mermaid-js class diagram from php code.
https://github.com/tasuku43/php-mermaid-class-diagram
class-diagram-generator classdiagram diagram diagrams mermaid mermaid-diagrams mermaidjs php
Last synced: 2 months ago
JSON representation
Generate Mermaid-js class diagram from php code.
- Host: GitHub
- URL: https://github.com/tasuku43/php-mermaid-class-diagram
- Owner: tasuku43
- License: mit
- Created: 2022-08-17T14:38:47.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-13T06:35:23.000Z (5 months ago)
- Last Synced: 2024-10-13T11:43:49.263Z (3 months ago)
- Topics: class-diagram-generator, classdiagram, diagram, diagrams, mermaid, mermaid-diagrams, mermaidjs, php
- Language: PHP
- Homepage:
- Size: 70.3 KB
- Stars: 7
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mermaid class diagram generater
## Overview
Generate Mermaid-js class diagram from php code.
This tool focuses on the relationships between classes and omits the details of class internals at this stage.
## Installation
Via Composer
```shell
composer require --dev tasuku43/mermaid-class-diagram
```## Usage
Here is an example run on a sample project
```shell
$ tree
.
├── composer.json
├── composer.lock
├── src
│ ├── SomeAbstractClass.php
│ ├── SomeClassA.php
│ ├── SomeClassB.php
│ ├── SomeClassC.php
│ ├── SomeClassD.php
│ ├── SomeClassE.php
│ └── SomeInterface.php
└── vendor
```
```php
class SomeClassA extends SomeAbstractClass
{
private SomeClassB $someClassB;public function __construct(private SomeClassC $someClassC, SomeClassD $someClassD, private int $int)
{
}
}class SomeClassB
{
}class SomeClassC
{
}class SomeClassD
{
}class SomeClassE
{
public function __construct(private SomeClassA $a)
{
$b = new SomeClassB;
}public function dependAandC(SomeClassA $a): SomeClassC
{
}
}abstract class SomeAbstractClass implements SomeInterface
{
}interface SomeInterface
{
}
```
### Execute command by specifying a directory
```shell
$ vendor/bin/mermaid-class-diagram generate --path src
classDiagram
class SomeAbstractClass {
<>
}
class SomeClassA {
}
class SomeClassB {
}
class SomeClassC {
}
class SomeClassD {
}
class SomeClassE {
}
class SomeInterface {
<>
}SomeInterface <|.. SomeAbstractClass: realization
SomeAbstractClass <|-- SomeClassA: inheritance
SomeClassA *-- SomeClassB: composition
SomeClassA *-- SomeClassC: composition
SomeClassD <.. SomeClassA: dependency
SomeClassE *-- SomeClassA: composition
SomeClassB <.. SomeClassE: dependency
SomeClassC <.. SomeClassE: dependency
```
```mermaid
classDiagram
class SomeAbstractClass {
<>
}
class SomeClassA {
}
class SomeClassB {
}
class SomeClassC {
}
class SomeClassD {
}
class SomeClassE {
}
class SomeInterface {
<>
}SomeInterface <|.. SomeAbstractClass: realization
SomeAbstractClass <|-- SomeClassA: inheritance
SomeClassA *-- SomeClassB: composition
SomeClassA *-- SomeClassC: composition
SomeClassD <.. SomeClassA: dependency
SomeClassE *-- SomeClassA: composition
SomeClassB <.. SomeClassE: dependency
SomeClassC <.. SomeClassE: dependency
```
### Execute command by specifying a file
```shell
$ vendor/bin/mermaid-class-diagram generate --path src/SomeClassA.php
classDiagram
class SomeClassA {
}SomeAbstractClass <|-- SomeClassA: inheritance
SomeClassA *-- SomeClassB: composition
SomeClassA *-- SomeClassC: composition
SomeClassD <.. SomeClassA: dependency
```
```mermaid
classDiagram
class SomeClassA {
}SomeAbstractClass <|-- SomeClassA: inheritance
SomeClassA *-- SomeClassB: composition
SomeClassA *-- SomeClassC: composition
SomeClassD <.. SomeClassA: dependency
```## License
The MIT License (MIT). Please see [LICENSE](https://github.com/tasuku43/php-mermaid-class-diagram/blob/main/LICENSE) for more information.