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

Editorconfig Laravel Package

idiosyncratic/editorconfig

PHP implementation of EditorConfig. Load .editorconfig rules via Composer and query settings for a given file path. Returns matching declarations as an array or prints the resolved config, making it easy to enforce consistent coding style across projects.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer: composer require idiosyncratic/editorconfig. Instantiate Idiosyncratic\EditorConfig\EditorConfig, then call getConfigForPath($filePath) to retrieve an associative array of resolved EditorConfig rules (e.g., ['indent_style' => 'space', 'trim_trailing_whitespace' => true]). For quick inspection or CLI debugging, use printConfigForPath($filePath) to output a human-readable config string. Start with a simple use case—like reading indentation rules for a PHP file—to verify baseline functionality.

Implementation Patterns

  • Code Quality Gates: Integrate into pre-commit hooks or CI (e.g., GitHub Actions) by wrapping EditorConfig in a command or service that asserts required rules (e.g., ensureIndentStyle('space')) before allowing builds to pass.
  • Dynamic Formatter Configuration: In custom linting/formatter scripts, pass file paths to getConfigForPath() and apply settings programmatically (e.g., adjust php-cs-fixer options per-file using resolved max_line_length or charset).
  • Repo Health Checks: Build a Laravel console command that walks project directories, aggregatesEditorConfig resolution, and reports inconsistencies (e.g., missing root = true, conflicting encodings across subfolders).
  • IDE Integration Hooks: Use the parser to generate per-file config metadata for editor plugins or LSP servers, enabling real-time feedback based on project-wide rules.

Gotchas and Tips

  • Staleness risk: Last updated in 2021; confirm PHP 8.2+ compatibility in your environment—test with real .editorconfig files before deploying to production.
  • Path edge cases: Always pass absolute paths; relative paths may yield incorrect cascading (e.g., missing root-level config). On Windows, verify globbing behavior is stable in your version (0.1.3+ fixes key issues here).
  • No validation layer: The parser returns raw strings/integers (e.g., indent_size might be '4' as a string)—add your own type coercion/validation if semantic correctness matters.
  • Caching imperative: For batch operations (e.g., 500+ files), cache parsed .editorconfig files manually; the class re-reads and re-parses on every getConfigForPath() call, even for identical project roots.
  • Non-standard extensions: Some teams use custom keys (e.g., php_cs_fixer.rules). While not spec-compliant, they work in practice—post-process results if you need to support vendor-specific overrides.
  • Comments & braces: # comments and {} wildcards ({src,tests}/*.php) work in 0.1.1+, but complex patterns (e.g., nested braces) may still misbehave—test with your actual .editorconfig.
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