Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

damms005's avatar

Laravel VS Code Extension for Databases

I need suggestions for my new VS Code extension for working with databases locally.

The marketplace link is https://marketplace.visualstudio.com/items?itemName=damms005.devdb

It currently provides code lens for Eloquent Models. What other useful integrations can I do for Laravel projects.

0 likes
3 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

It's great to hear that you're developing a VS Code extension for working with databases in Laravel projects. Here are some suggestions for features that could be useful to integrate into your extension:

  1. Database Schema Visualization: Provide a feature that allows developers to visualize their database schema directly within VS Code. This could include tables, columns, types, indexes, and relationships.

  2. Migration Management: Offer an easy way to create, run, and rollback migrations. This could include generating migration files from existing database structures or scaffolding new ones.

  3. Seed & Factory Integration: Allow developers to easily generate and run seeders and factories from within VS Code, which can be very handy for setting up test data.

  4. Query Builder Assistance: Integrate a feature that helps with writing and testing Laravel's query builder syntax. This could include autocomplete for table names, column names, and query builder methods.

  5. Eloquent Relationship Tracing: Provide a way to trace and visualize Eloquent relationships from models. This could help developers understand how models are connected.

  6. SQL Query Execution: Allow developers to write and execute raw SQL queries within VS Code and view the results. This could be particularly useful for quick database checks or data exploration.

  7. Performance Analysis: Integrate a feature that can analyze queries for performance issues, such as detecting N+1 problems or suggesting indexes.

  8. Database Seed & Migration Status: Show the current status of migrations and whether the database is seeded, possibly with a quick option to refresh or reset the database.

  9. Artisan Command Integration: Provide shortcuts for common Artisan commands related to databases, such as php artisan migrate, php artisan db:seed, etc.

  10. Database Configuration Management: Offer a simple interface for managing database connections and environment configurations.

Here's a sample code snippet for a possible feature that could generate a migration file from within VS Code:

const vscode = require('vscode');

function generateMigration() {
    const editor = vscode.window.activeTextEditor;
    if (!editor) {
        vscode.window.showErrorMessage("You need to open a file to generate a migration.");
        return;
    }

    const modelName = editor.document.fileName.split('/').pop().replace('.php', '');
    const tableName = modelName.toLowerCase() + 's'; // Simple pluralization logic

    const migrationName = `create_${tableName}_table`;
    const command = `php artisan make:migration ${migrationName} --create=${tableName}`;

    const terminal = vscode.window.createTerminal('Laravel Migrations');
    terminal.show();
    terminal.sendText(command);
}

// This command could be registered in the extension's activation function
context.subscriptions.push(vscode.commands.registerCommand('extension.generateMigration', generateMigration));

Remember to listen to the community feedback and prioritize features based on what your users find most valuable. Good luck with your VS Code extension!

1 like
jlrdw's avatar

There are videos free covering VS code.

Please or to participate in this conversation.