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

Yoastcs Laravel Package

yoast/yoastcs

Yoast Coding Standards (YoastCS) provides Composer-installable rulesets for PHP_CodeSniffer plus PHP Parallel Lint, bundling Yoast sniffs and selected external standards (including WordPress). Use it to enforce consistent code style and quality in Yoast projects.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Enforce Consistent Code Quality: Adopt YoastCS to standardize PHP/Laravel codebases across teams, reducing technical debt and improving maintainability. Aligns with WordPress/WP VIP standards while adding Yoast-specific best practices.
  • CI/CD Integration: Mandate PHPCS and Parallel Lint checks in pipelines to block non-compliant code (e.g., parse errors, deprecated functions) before merge. Example: Fail builds if YOASTCS_THRESHOLD_ERRORS is exceeded.
  • Developer Onboarding: Reduce ramp-up time by providing clear, automated feedback via IDE plugins (PhpStorm) or CLI tools. Example: Integrate composer check-cs-warnings in pre-commit hooks.
  • PHP Version Compatibility: Future-proof Laravel projects by enforcing PHPCompatibilityWP rules, avoiding breaking changes when upgrading PHP (e.g., 7.4→8.4). Example: Use YOASTCS_THRESHOLD_WARNINGS to track deprecation warnings.
  • Custom Standards: Extend YoastCS to enforce domain-specific rules (e.g., "Disallow trailing commas in single-line function calls") via custom sniffs or .phpcs.xml.dist overrides.
  • Build vs. Buy: Avoid reinventing PHPCS rulesets; leverage Yoast’s battle-tested configuration (e.g., WordPressCS + Slevomat) to save engineering time.
  • Use Cases:
    • Laravel Plugins/Themes: Enforce WordPress-specific standards (e.g., WordPress.WP.GetMetaSingle) while using Laravel’s Eloquent.
    • Legacy Migration: Gradually improve code quality in monolithic apps by setting incremental thresholds (e.g., YOASTCS_THRESHOLD_ERRORS=50).
    • Open-Source Contributions: Align PRs with Yoast’s standards if collaborating with their ecosystem.

When to Consider This Package

  • Adopt YoastCS if:

    • Your team works with Laravel + WordPress (e.g., custom plugins, themes, or headless CMS integrations).
    • You need PHP 7.4+ compatibility checks with WordPress-specific rules (e.g., avoiding get_option() in favor of Laravel’s config).
    • You want pre-configured PHPCS rules that balance strictness (errors = blocker) and flexibility (warnings = recommended).
    • Your CI/CD pipeline lacks static analysis for parse errors or deprecated functions (e.g., parallel-lint + PHPCompatibilityWP).
    • You’re building high-traffic Laravel apps where code quality directly impacts performance (e.g., VIP standards for caching).
  • Look Elsewhere if:

    • Your stack is non-PHP (e.g., Node.js, Python) or non-Laravel (e.g., Symfony with its own standards).
    • You need language-agnostic linting (e.g., ESLint for JavaScript).
    • Your team prefers minimalist standards (e.g., PSR-12 only) over Yoast’s extended ruleset.
    • You’re constrained by legacy PHP <7.2 (YoastCS defaults to PHP 7.4+).
    • Your project has unique compliance requirements (e.g., HIPAA) not covered by Yoast’s sniffs.

How to Pitch It (Stakeholders)

For Executives:

"YoastCS lets us enforce best practices for PHP/Laravel code—like auto-fixing deprecated functions or catching syntax errors before they hit production—while aligning with WordPress’s ecosystem. This reduces bugs, speeds up onboarding, and future-proofs our stack. For example, we can block PHP 7.4 deprecations in CI, saving dev time on critical fixes. It’s like having a senior engineer review every line of code, automatically."

Ask: "Should we mandate this for all new Laravel projects to cut technical debt?"

For Engineers:

*"YoastCS gives us:

  1. PHPCS + Parallel Lint: Catch parse errors and style issues early (e.g., composer lint in CI).
  2. WordPress + Laravel Hybrid Rules: Enforce WordPress standards (e.g., get_post_meta()) while using Laravel’s Eloquent.
  3. Threshold-Based Gates: Set YOASTCS_THRESHOLD_ERRORS=0 to block bad code, or =50 for gradual fixes.
  4. IDE Integration: PhpStorm autofixes issues as you code (e.g., trailing commas, heredoc spacing).
  5. Future-Proofing: PHPCompatibilityWP flags deprecated functions before they break us.

Example workflow:

# Add to composer.json
composer require --dev yoast/yoastcs

# Run in CI
composer check-cs-warnings && composer check-cs-thresholds

Ask: "Want to trial this on [Project X] to see how it catches issues we’re missing?"

For PMs:

*"This is a low-effort, high-impact tool to:

  • Reduce bugs: Catch 80% of PHP issues before QA (e.g., parse errors, deprecated functions).
  • Standardize code: Avoid ‘code smell’ debates by enforcing Yoast’s rules (e.g., no exit() without parentheses).
  • Save time: Automate reviews for PRs with composer check-cs-warnings.
  • Align with WordPress: Critical if we’re building plugins/themes or integrating with WP.

Tradeoff: It’s stricter than PSR-12, but we can override rules per project if needed."*

Ask: "Should we add this to our default Laravel template to enforce consistency?"

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
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
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