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

Markdowndocs Laravel Package

victorjonsson/markdowndocs

Generate single-page Markdown API docs from PHP DocBlocks. Install via Composer and run phpdoc-md to scan your source, include public/protected methods, respect @ignore, and infer missing types using reflection.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • DocBlock Integration: Aligns with Laravel’s existing PHP DocBlock standards (e.g., PHPDoc, PHPDoc annotations), reducing friction for adoption.
    • CLI-Driven: Fits seamlessly into Laravel’s CLI-centric workflow (e.g., Artisan commands, php artisan).
    • Lightweight: No heavy dependencies; leverages PHP’s built-in Reflection API, which Laravel already uses (e.g., for route/model binding).
    • Markdown Output: Compatible with Laravel’s ecosystem (e.g., Markdown-based documentation in laravel.com, laravel-news.com, or custom wiki systems).
  • Cons:

    • Outdated: Last release in 2016 raises concerns about compatibility with modern PHP (8.x) and Laravel (10.x+).
    • Limited Customization: Hardcoded output format may not align with Laravel’s theming (e.g., Blade templates, Tailwind CSS docs).
    • No Laravel-Specific Features: Lacks native support for Laravel artifacts (e.g., Facades, Service Providers, Blade directives).

Integration Feasibility

  • High for Core Codebases:
    • Works natively with Laravel’s autoloader (Composer-based) and Reflection usage.
    • Can be triggered via Artisan commands (e.g., php artisan docs:generate) for CI/CD integration.
  • Challenges for Custom Cases:
    • Namespaced Classes: Laravel’s app/ structure (e.g., App\Services\*) may require explicit path configuration.
    • Dynamic Classes: Classes generated at runtime (e.g., via eval() or dynamic proxies) won’t be documented.
    • Non-Standard DocBlocks: Laravel’s unique annotations (e.g., @mixin, @route) may not render correctly.

Technical Risk

  • Compatibility Risks:
    • PHP 8.x: May fail due to deprecated features (e.g., foreach by reference) or strict typing.
    • Laravel-Specific Edge Cases: Facades, macros, or dynamic properties might not reflect accurately.
  • Maintenance Risk:
    • Abandoned Project: No active development or community support.
    • Security: No recent updates may introduce vulnerabilities (though MIT license mitigates this slightly).
  • Functional Gaps:
    • No API Route Docs: Cannot document Laravel routes (e.g., Route::get()) or controllers.
    • No Blade Template Docs: Ignores Laravel’s templating logic.

Key Questions

  1. Compatibility:
    • Does the package work with PHP 8.2+ and Laravel 10.x? (Test with phpunit/phpunit@^10 and laravel/framework@^10.)
    • How does it handle Laravel’s Illuminate\Support\Facades or dynamic properties?
  2. Output Customization:
    • Can the Markdown template be extended to include Laravel-specific sections (e.g., "Routes," "Middleware")?
  3. CI/CD Integration:
    • How to trigger docs generation in GitHub Actions/GitLab CI without manual CLI calls?
  4. Alternatives:
    • Should we evaluate modern tools like phpDocumentor, Docz, or Laravel’s built-in php artisan doc (if available)?
  5. Long-Term Viability:
    • Is there a plan to fork/maintain this package, or should we invest in a custom solution?

Integration Approach

Stack Fit

  • Laravel Ecosystem:
    • Artisan Integration: Wrap phpdoc-md in a custom Artisan command (e.g., php artisan docs:generate) for consistency.
    • Service Provider: Register the command in AppServiceProvider with configurable paths (e.g., config/docs.php).
    • Markdown Pipeline: Use Laravel’s File facade or Storage to save/output Markdown to storage/docs/ or public/docs/.
  • Tooling Compatibility:
    • Git Hooks: Auto-generate docs on pre-commit or pre-push (via composer post-update-cmd).
    • IDE Support: Ensure generated Markdown is indexed by PHPStorm/WebStorm for quick navigation.

Migration Path

  1. Pilot Phase:
    • Test on a non-critical Laravel module (e.g., a legacy app/Modules/ directory).
    • Compare output with manually written docs for accuracy.
  2. Incremental Rollout:
    • Start with core app/Http/Controllers/ and app/Services/ directories.
    • Exclude dynamic classes (e.g., Eloquent models with complex relationships) initially.
  3. Customization Layer:
    • Extend the Markdown template to include Laravel-specific tags (e.g., @route, @middleware).
    • Use a post-processing script (e.g., PHP or JavaScript) to enrich the output.

Compatibility

  • PHP/Laravel:
    • Polyfills: Add phpdoc-md to composer.json with ^1.0 but pin to a specific version (e.g., 1.0.0) to avoid breaking changes.
    • Bootstrap: Use Laravel’s bootstrap/app.php as the --bootstrap file to ensure all autoloading is in place.
  • Path Configuration:
    • Configure config/docs.php to define:
      'paths' => [
          'src' => ['app/Http', 'app/Services'],
          'ignore' => ['app/Tests', 'vendor'],
      ],
      
  • Output Handling:
    • Redirect output to a file:
      ./vendor/bin/phpdoc-md generate app/Http > storage/docs/api.md
      
    • Use Laravel’s File facade to append timestamps or version info.

Sequencing

  1. Pre-requisites:
    • Ensure Reflection is enabled in php.ini (default in Laravel).
    • Standardize DocBlocks across the codebase (e.g., via roave/phpstan-baseline or custom linting).
  2. Initial Setup:
    • Add to composer.json:
      "require-dev": {
          "victorjonsson/markdowndocs": "1.0.0"
      }
      
    • Create a custom Artisan command:
      php artisan make:command DocsGenerate
      
  3. Testing:
    • Validate output for 1–2 classes manually.
    • Automate in CI (e.g., GitHub Actions):
      - name: Generate Docs
        run: php artisan docs:generate
      
  4. Post-Launch:
    • Monitor for missing/incorrect entries (e.g., private methods, dynamic classes).
    • Explore integration with Laravel Forge or Deployer for remote doc generation.

Operational Impact

Maintenance

  • Pros:
    • Low Overhead: Minimal runtime impact; runs during build/deploy phases.
    • Self-Documenting: Reduces manual doc maintenance (e.g., no sync needed between code and Markdown).
  • Cons:
    • DocBlock Management: Requires developers to keep DocBlocks updated (adds to PR reviews).
    • Tool Dependency: If phpdoc-md breaks, docs generation fails (mitigate with fallback scripts).
  • Mitigations:
    • CI Checks: Fail builds if DocBlocks are missing (e.g., via PHPStan rules).
    • Fallback: Maintain a backup script (e.g., Python + pydoc-markdown) if the package becomes unusable.

Support

  • Developer Onboarding:
    • Training: Document how to write DocBlocks for Laravel-specific cases (e.g., Facades, macros).
    • Templates: Provide a DocBlock.md guide in the repo with examples for controllers, services, and models.
  • Troubleshooting:
    • Common Issues:
      • "Class not found" → Verify Composer autoload (composer dump-autoload).
      • "Missing methods" → Check for @ignore tags or private/protected methods.
    • Debugging: Log phpdoc-md output to storage/logs/docs.log for errors.

Scaling

  • Performance:
    • Large Codebases: Reflection can be slow for 10K+ classes. Optimize by:
      • Excluding vendor/ and node_modules/ directories.
      • Running in parallel (e.g., split by namespace).
    • CI Limits: May hit timeout in GitHub Actions. Use php artisan docs:generate --parallel (if supported) or split into multiple steps.
  • Storage:
    • Markdown Files: Store in storage/docs/ (excluded from Git) or public/docs/ (versioned).
    • Size: Compress large files or split into per-module docs (e.g., api-controllers.md, api-services.md).

Failure Modes

Failure Scenario Impact Mitigation
phpdoc-md CLI fails Docs not generated Fallback to manual process or script.
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.
terminal42/code-quality-tools
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