Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doc Laravel Package

chatgpt/doc

Laravel package that adds a /chatgpt-doc route to serve helpful OpenAI and ChatGPT documentation. Install via Composer; optionally register the service provider if auto-discovery is disabled. No specific PHP or Laravel version dependency.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require dev-arindam-roy/chatgpt-doc
    

    Add the service provider to config/app.php:

    'providers' => [
        // ...
        DevArindamRoy\ChatGPTDoc\ChatGPTDocServiceProvider::class,
    ],
    
  2. Publish Config (Optional)

    php artisan vendor:publish --provider="DevArindamRoy\ChatGPTDoc\ChatGPTDocServiceProvider"
    

    Configure API keys and endpoints in config/chatgpt-doc.php.

  3. First Use Case Fetch OpenAI API documentation dynamically in a controller:

    use DevArindamRoy\ChatGPTDoc\Facades\ChatGPTDoc;
    
    public function showDocs()
    {
        $docs = ChatGPTDoc::getDocumentation('completions');
        return view('docs', ['docs' => $docs]);
    }
    

Implementation Patterns

Core Workflows

  1. Dynamic Documentation Fetching

    // Fetch API reference for a specific endpoint
    $completionsDocs = ChatGPTDoc::getDocumentation('completions');
    
    // Fetch all available endpoints
    $allEndpoints = ChatGPTDoc::listEndpoints();
    
  2. Integration with Laravel Routes

    Route::get('/docs/{endpoint}', function ($endpoint) {
        return ChatGPTDoc::getDocumentation($endpoint);
    })->name('api.docs');
    
  3. Caching for Performance

    // Cache docs for 1 hour
    $docs = ChatGPTDoc::getDocumentation('models', 3600);
    
  4. Blade Integration

    @foreach($docs['parameters'] as $param)
        <div class="param">
            <strong>{{ $param['name'] }}</strong>: {{ $param['description'] }}
        </div>
    @endforeach
    

Advanced Patterns

  • Custom Documentation Storage Extend the package to store fetched docs in a database:

    ChatGPTDoc::storeDocumentation('models', $rawDocs);
    
  • API Versioning

    // Fetch v1 docs
    $v1Docs = ChatGPTDoc::getDocumentation('models', null, 'v1');
    
  • Event Listeners Listen for ChatGPTDoc.Fetched events to log or process docs:

    ChatGPTDoc::getDocumentation('files')->then(function ($docs) {
        event(new DocsFetched($docs));
    });
    

Gotchas and Tips

Common Pitfalls

  1. Rate Limiting

    • The package respects OpenAI’s rate limits. Cache aggressively or implement exponential backoff:
      try {
          $docs = ChatGPTDoc::getDocumentation('engines');
      } catch (\DevArindamRoy\ChatGPTDoc\Exceptions\RateLimitExceeded $e) {
          sleep($e->retryAfter);
          retry();
      }
      
  2. Deprecated Endpoints

    • Some endpoints (e.g., engines) are deprecated. Use ChatGPTDoc::isDeprecated('engines') to check.
  3. Configuration Overrides

    • Avoid hardcoding API keys. Use Laravel’s .env:
      CHATGPT_DOC_API_KEY=your_key_here
      

Debugging Tips

  • Enable Debug Mode

    ChatGPTDoc::setDebug(true); // Logs HTTP requests/responses
    
  • Validate Responses

    $docs = ChatGPTDoc::getDocumentation('files');
    if (!ChatGPTDoc::isValidResponse($docs)) {
        Log::error('Invalid docs response', ['response' => $docs]);
    }
    

Extension Points

  1. Custom Data Sources Override the default OpenAI source:

    ChatGPTDoc::setSource(new CustomChatGPTDocSource());
    
  2. Response Transformers Modify raw responses before processing:

    ChatGPTDoc::setTransformer(function ($raw) {
        return collect($raw)->map(fn ($item) => [
            'name' => $item['id'],
            'description' => $item['purpose'],
        ]);
    });
    
  3. Authentication Extend for enterprise/private API keys:

    ChatGPTDoc::setAuth(new BearerTokenAuth('your_enterprise_key'));
    

Performance

  • Lazy Loading Use ChatGPTDoc::lazyLoad('models') to fetch docs only when accessed in Blade:

    @lazyLoad('models')
        @include('partials.model-docs')
    @endLazyLoad
    
  • Selective Field Loading

    $docs = ChatGPTDoc::getDocumentation('files', null, null, ['id', 'description']);
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor