Complete Documentation Guide

Learn how to install, configure, and use Laradoc to generate comprehensive documentation for your Laravel applications.

Laradoc Documentation

Installation

Step 1: Install via Composer
composer require codewithuali/laradoc

View on Packagist

Step 2: Publish Configuration
php artisan vendor:publish --provider="Laradoc\LaradocServiceProvider"
Step 3: Run Migrations
php artisan migrate
Step 4: Configure Environment Variables

Add the following to your .env file:

# AI Provider Configuration
LARADOC_AI_PROVIDER=openai
LARADOC_OPENAI_API_KEY=your_openai_api_key
LARADOC_OPENAI_MODEL=gpt-4

# Optional: Claude AI
LARADOC_CLAUDE_API_KEY=your_claude_api_key

# Optional: Google Gemini
LARADOC_GEMINI_API_KEY=your_gemini_api_key

# Search Configuration
LARADOC_SEARCH_DRIVER=meilisearch
LARADOC_MEILISEARCH_HOST=http://localhost:7700
LARADOC_MEILISEARCH_KEY=your_meilisearch_key

Configuration

AI Provider Settings

Laradoc supports multiple AI providers for generating documentation:

  • OpenAI: GPT-4, GPT-3.5-turbo
  • Claude: Claude-3, Claude-2
  • Gemini: Gemini Pro, Gemini Flash

Configure your preferred provider in the config/laradoc.php file:

'ai' => [
    'provider' => env('LARADOC_AI_PROVIDER', 'openai'),
    'openai' => [
        'api_key' => env('LARADOC_OPENAI_API_KEY'),
        'model' => env('LARADOC_OPENAI_MODEL', 'gpt-4'),
    ],
    'claude' => [
        'api_key' => env('LARADOC_CLAUDE_API_KEY'),
        'model' => env('LARADOC_CLAUDE_MODEL', 'claude-3-sonnet'),
    ],
    'gemini' => [
        'api_key' => env('LARADOC_GEMINI_API_KEY'),
        'model' => env('LARADOC_GEMINI_MODEL', 'gemini-pro'),
    ],
],
Search Configuration

Configure search functionality with Meilisearch or database fallback:

'search' => [
    'driver' => env('LARADOC_SEARCH_DRIVER', 'meilisearch'),
    'meilisearch' => [
        'host' => env('LARADOC_MEILISEARCH_HOST', 'http://localhost:7700'),
        'key' => env('LARADOC_MEILISEARCH_KEY'),
        'index' => env('LARADOC_MEILISEARCH_INDEX', 'laradoc'),
    ],
],

Usage

Generate Documentation

Run the documentation generation command:

php artisan laradoc:generate

This will analyze your Laravel application and generate comprehensive documentation.

Access Web Interface

Visit /laradoc in your browser to access the web interface:

http://your-app.com/laradoc

The web interface provides:

  • Documentation viewer with search
  • AI-powered chatbot
  • Document editing capabilities
  • Export functionality
Console Commands

Available Artisan commands:

  • laradoc:generate - Generate documentation
  • laradoc:analyze - Analyze specific components
  • laradoc:export - Export documentation
  • laradoc:search - Rebuild search index

Features Overview

Database Analysis

Automatically analyzes migrations, models, and relationships to document your data structure.

Route Documentation

Comprehensive route analysis including middleware, parameters, and controller methods.

Validation Rules

Extract and document validation rules from form requests and controllers.

AI-Powered Insights

Generate intelligent documentation and code explanations using multiple AI providers.

API Reference

LaradocService Class

Main service class for generating documentation:

use Laradoc\Services\LaradocService;

$laradoc = app(LaradocService::class);

// Generate full documentation
$laradoc->generate();

// Analyze specific components
$laradoc->analyzeModels();
$laradoc->analyzeRoutes();
$laradoc->analyzeControllers();
Search Service

Search through documentation:

use Laradoc\Services\SearchService;

$search = app(SearchService::class);

// Search documentation
$results = $search->search('user authentication');

// Rebuild search index
$search->rebuildIndex();

Troubleshooting

Check your API keys and configuration:

  • Verify API keys are set in .env
  • Check API provider status
  • Ensure correct model names

For Meilisearch issues:

  • Check Meilisearch server is running
  • Verify connection settings
  • Rebuild search index: php artisan laradoc:search

Common issues and solutions:

  • Check file permissions
  • Verify Laravel application structure
  • Run with verbose output: php artisan laradoc:generate -v

Need More Help?

Can't find what you're looking for? Our support team is here to help.