PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Written By
Views

Running Laravel IDE Helper Generator automatically

Running Laravel IDE Helper Generator automatically

When working on Laravel projects, I always try to keep working on hooks and automation.

There is no exception in this case when using the package barryvdh/laravel-ide-helper that generates helper files that enable your IDE to provide accurate autocompletion.

If you are working on a project where you regularly add database migrations then you will definitely find it handy to automatically call the command to generate those helpers.

The solution is very simple. Just register event listener MigrationsEnded in the file app/Providers/EventServiceProvider.php.

Event::listen(
    \Illuminate\Database\Events\MigrationsEnded::class,
    function () {
        Artisan::call('ide-helper:models -r -W');
    }
);

You can customize the artisan command according to your needs.

Of course, I recommend creating the same command for the composer.json:

{
    ...,
    "scripts": {
        "schema": "php artisan ide-helper:models -r -W"
    }
}

Then just simply run:

composer run scripts

Comments (0)

loading comments