1. Go to this page and download the library: Download rtcoder/laravel-db-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/ */
rtcoder / laravel-db-erd example snippets
use Rtcoder\LaravelERD\Contracts\ERDGeneratorInterface;
class ExportSchemaController
{
public function __invoke(ERDGeneratorInterface $generator): void
{
$generator->generate(storage_path('erd/schema.svg'), 'pgsql');
}
}
namespace App\Http\Controllers;
use Rtcoder\LaravelERD\Contracts\ERDGeneratorInterface;
class ExportSchemaController
{
public function __invoke(ERDGeneratorInterface $generator): string
{
$path = storage_path('erd/schema.svg');
$generator->generate($path, 'pgsql');
return $path;
}
}
namespace App\Jobs;
use Rtcoder\LaravelERD\Contracts\ERDGeneratorInterface;
class GenerateSchemaDiagram
{
public function handle(ERDGeneratorInterface $generator): void
{
$generator->generate(storage_path('erd/schema.html'), config('erd.default_driver'));
}
}