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

Rule Doc Generator Contracts Laravel Package

symplify/rule-doc-generator-contracts

Contracts for Symplify’s rule doc generator: shared interfaces and value objects used to describe, format, and export rule documentation across Symplify tools. Useful when building custom rule providers, printers, or integrations without depending on full implementations.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing the package as a dev dependency: composer require --dev symplify/rule-doc-generator-contracts. Then, locate and implement the RuleDocumentationInterface in your custom rule classes — this is your primary entry point. As a Laravel developer, you’ll use this when building reusable StaticAnalysis or Rector-like tools for your codebase (e.g., internal coding standards enforcement), where consistent rule documentation is needed across projects. Your first step is to define basic metadata: rule title, description, and code examples.

Implementation Patterns

Integrate by decorating your rule classes with RuleDocumentationInterface, then programmatically consume the metadata in CLI tools, Laravel commands, or documentation generators. For example:

  • Create a php artisan docs:rules command that scans your app’s rules directory and renders HTML/Markdown docs.
  • Embed getDescription() output as inline IDE hints or hover tooltips in custom language servers.
  • Reuse getInvalidCode()/getValidCode() to auto-generate before/after diffs in your CI reports or Confluence pages. This pattern keeps your rule metadata executable — not just comments — enabling automated validation, searching, and filtering of rules in tooling ecosystems.

Gotchas and Tips

  • The package has no runtime behavior — it’s only interfaces. If your rule doesn’t implement the contract, doc generation silently skips it. Always verify instanceof RuleDocumentationInterface before consuming data.
  • Metadata drift is common: Titles/descriptions often become stale. Add a phpunit test that asserts getDescription() isn’t empty or contains a versioned changelog hint.
  • No built-in autodiscovery or configuration — you’ll need to maintain a registry of rules manually or via reflection. For large codebases, build a static cache of metadata to avoid repeated class instantiation.
  • Minimize coupling: Avoid referencing full generators (e.g., symplify/rule-doc-generator) in production. Keep this dependency strictly in require-dev and isolated to doc-generation scripts.
  • Tip: Use the same markdown in getDescription() for both CLI usage (php artisan rules) and user-facing docs — consistency reduces maintenance cost and improves adoption.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation