recca0120 / laravel-erd

Laravel ERD automatically generates Entity-Relationship Diagrams from your Laravel models and displays them using erd-editor.
MIT License
259 stars 11 forks source link

Failed to use the erd:install command #1

Open baruchsheffi opened 2 months ago

baruchsheffi commented 2 months ago

composer require recca0120/laravel-erd:^0.1 --dev // that one went well sail artisan erd:generate // that one works great, it created docs/erd/index.html perfectly I wanted to generate SVG version... sail artisan erd:install this is the result: TypeError

Recca0120\LaravelErd\Console\Commands\InstallBinary::downloadErdGo(): Argument #3 ($path) must be of type string, null given, called in /var/www/html/vendor/recca0120/laravel-erd/src/Console/Commands/InstallBinary.php on line 42

at vendor/recca0120/laravel-erd/src/Console/Commands/InstallBinary.php:56 52▕ 53▕ /* 54▕ @throws ClientExceptionInterface 55▕ */ ➜ 56▕ private function downloadErdGo(string $platform, string $arch, string $path): void 57▕ { 58▕ $extension = $platform === Platform::WINDOWS ? '.exe' : ''; 59▕ $arch = $platform === Platform::LINUX && $arch === Platform::ARM ? Platform::ARM : 'amd64'; 60▕

  +14 vendor frames 

15 artisan:35 Illuminate\Foundation\Console\Kernel::handle()

I tried with "sail root-bash" using "php artisan erd:install" and i got same result.

dekmabot commented 2 months ago

It is because LARAVEL_ERD_GO and LARAVEL_ERD_DOT env variables are not defined in vendor/recca0120/laravel-erd/config/laravel-erd.php, and the default value was removed in commit. It also has not been defined in envionment.

I returned variables to config

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

Then added packages:

apk add erd-go
apk add graphviz

But still I have dependency problem: Class "Http\Client\Common\Plugin\ErrorPlugin" not found.

Then I added composer require php-http/client-common --dev and everything become fine:

/var/www/html # php artisan erd:install
download: https://github.com/kaishuu0123/erd-go/releases/download/v2.0.0/linux_amd64_erd-go
download: https://github.com/kaishuu0123/graphviz-dot.js/releases/download/v0.3.1/graphviz-dot-linux-x64

Now my charts are working!

My env is Laravel 11, Alpine 3.20, PHP 8.3.7.