PHP code example of recca0120 / laravel-erd

1. Go to this page and download the library: Download recca0120/laravel-erd 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/ */

    

recca0120 / laravel-erd example snippets


return [
    // Route URI for the web viewer
    'uri' => env('LARAVEL_ERD_URI', 'laravel-erd'),

    // Where generated files are stored
    'storage_path' => storage_path('framework/cache/laravel-erd'),

    // Default output extension (when --file is not specified)
    'extension' => env('LARAVEL_ERD_EXTENSION', 'sql'),

    // Middleware for the web viewer route
    'middleware' => [],

    // Paths to erd-go and graphviz-dot binaries
    'binary' => [
        'erd-go' => env('LARAVEL_ERD_GO', '/usr/local/bin/erd-go'),
        'dot' => env('LARAVEL_ERD_DOT', '/usr/local/bin/dot'),
    ],

    // Per-connection database overrides (see below)
    'connections' => [],
];

'storage_path' => base_path('docs/erd'),

'middleware' => ['auth'],

'connections' => [
    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
    ],
],
bash
php artisan erd:generate
bash
php artisan erd:install
bash
php artisan erd:generate --file=erd.svg
bash
php artisan erd:generate {database?} {--directory=} {--file=} {--path=} {--regex=} {--excludes=} {--graceful}
bash
# Basic generation
php artisan erd:generate

# Exclude specific tables
php artisan erd:generate --file=clean.sql --excludes=jobs,failed_jobs,cache

# Scan a specific directory
php artisan erd:generate --directory=app/Models

# Generate SVG
php artisan erd:generate --file=diagram.svg

# Use a different database connection
php artisan erd:generate mysql

# Print error instead of throwing exception
php artisan erd:generate --graceful
bash
php artisan vendor:publish --provider="Recca0120\LaravelErd\LaravelErdServiceProvider"
bash
# Publish everything (config, views, frontend assets)
php artisan vendor:publish --provider="Recca0120\LaravelErd\LaravelErdServiceProvider"