PHP code example of herrira / mermaid

1. Go to this page and download the library: Download herrira/mermaid library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

herrira / mermaid example snippets


use Herrira\Mermaid\ClassDiagram\Builder;

$builder = new Builder();
$builder->inheritance('Duck', 'Animal')
    ->inheritance('Fish', 'Animal')
    ->inheritance('Zebra', 'Animal')
    ->publicAttribute('Animal', 'age', 'int')
    ->publicAttribute('Animal', 'gender', 'String')
    ->publicMethod('Animal', 'isMammal')
    ->publicMethod('Animal', 'mate')
    ->class(function ($class) {
        $class->name('Duck')
            ->publicAttribute('beakColor', 'String')
            ->publicMethod('swim')
            ->publicMethod('quack');
    })
    ->class(function ($class) {
        $class->name('Fish')
            ->privateAttribute('sizeInFeet', 'int')
            ->privateMethod('canEat');
    })
    ->class(function ($class) {
        $class->name('Zebra')
            ->publicAttribute('is_wild', 'bool')
            ->publicMethod('run');
    });