← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

EditorConfig for PHP Projects

Style Beginner
debt(d7/e1/b3/t5)
d7 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'only careful code review or runtime testing' (d7). Mixed tabs/spaces and CRLF/LF issues are silent during development and only surface during code review when spurious diffs appear, or when CI linting runs phpcs/php-cs-fixer. The detection_hints list editorconfig, phpcs, and php-cs-fixer as tools, but these require deliberate setup — without them, the issue is invisible until a diff review catches whitespace noise.

e1 Effort Remediation debt — work required to fix once spotted

Closest to 'one-line patch or single-call swap' (e1). The quick_fix explicitly states: add a .editorconfig file to the repository root. This is a single file addition that immediately enforces consistent settings across all editors. The common_mistakes (not committing it, missing plugins) are equally trivial to fix.

b3 Burden Structural debt — long-term weight of choosing wrong

Closest to 'localised tax' (b3). The .editorconfig file lives at the project root and imposes a one-time setup cost (committing the file, installing plugins for editors that need them). The ongoing tax is minimal — it passively enforces style without requiring changes to workflow. It applies to web and cli contexts but doesn't shape architecture or slow down work streams.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap — a documented gotcha most devs eventually learn' (t5). The misconception field explicitly states the canonical wrong belief: 'EditorConfig is redundant if the team uses the same IDE.' This is a well-documented gotcha — teams discover it only when a new team member joins with a different OS or editor and introduces CRLF noise or tab/space mixing into diffs.

About DEBT scoring →

Also Known As

.editorconfig EditorConfig file editor settings file

TL;DR

A .editorconfig file enforces consistent indentation, line endings, and charset across all editors without relying on individual developer setup.

Explanation

EditorConfig defines per-file-type settings (indent_style, indent_size, end_of_line, charset, trim_trailing_whitespace, insert_final_newline) in a .editorconfig at the project root. Most editors support it natively (PhpStorm, VS Code) or via plugin. For PHP projects: indent_style = space, indent_size = 4 (PSR-12), end_of_line = lf, charset = utf-8. EditorConfig catches whitespace inconsistencies before they reach the linter — a developer on Windows won't accidentally commit CRLF line endings. Pair with .gitattributes text=auto for consistent line endings in the repository itself regardless of developer OS.

Common Misconception

EditorConfig is redundant if the team uses the same IDE. EditorConfig enforces consistent indentation, line endings, and charset across all editors and IDEs — without it, mixed tabs/spaces and Windows CRLF line endings silently corrupt diffs when team members use different tools.

Why It Matters

EditorConfig defines consistent indentation, line endings, and encoding across editors and operating systems — preventing whitespace-only diffs that obscure real changes in code review.

Common Mistakes

  • Not committing .editorconfig — only the developer who created it benefits.
  • Not installing the EditorConfig plugin for editors that require it (VS Code, Vim, Emacs).
  • Mixing tabs and spaces in a project without .editorconfig enforcing one style.
  • Windows CRLF line endings in a Unix project causing spurious diffs — .editorconfig enforces LF.

Code Examples

✗ Vulnerable
# No .editorconfig — every developer uses different settings:
# Dev A: 4-space indent, LF
# Dev B: 2-space indent, CRLF
# Dev C: tabs, LF
# git diff shows whitespace changes mixed with real changes in every PR

# .editorconfig:
root = true
[*.php]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
✓ Fixed
# .editorconfig — consistent editor settings across all contributors
root = true

[*]
charset             = utf-8
end_of_line         = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.php]
indent_style = space
indent_size  = 4

[*.{yml,yaml}]
indent_style = space
indent_size  = 2

[*.json]
indent_style = space
indent_size  = 2

[Makefile]
indent_style = tab

[*.md]
trim_trailing_whitespace = false  # markdown uses trailing spaces for line breaks

# Supported by: VS Code (EditorConfig extension), PhpStorm (built-in), Vim, Emacs, Sublime

Added 15 Mar 2026
Edited 22 Mar 2026
Views 66
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 1 ping T 3 pings F 0 pings S 4 pings S 2 pings M 2 pings T 3 pings W 1 ping T 1 ping F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Scrapy 12 Perplexity 9 Amazonbot 9 Ahrefs 6 SEMrush 5 Unknown AI 3 Majestic 2 Bing 2 ChatGPT 2 Claude 1 Meta AI 1 Google 1 Sogou 1
crawler 51 crawler_json 2 pre-tracking 1
DEV INTEL Tools & Severity
🟢 Low ⚙ Fix effort: Low
⚡ Quick Fix
Add a .editorconfig file to your repository root — it enforces consistent indentation, line endings, and charset across all editors without requiring per-developer IDE setup
📦 Applies To
any web cli
🔗 Prerequisites
🔍 Detection Hints
Mixed tabs and spaces in PHP files; inconsistent line endings CRLF LF mixed; files without final newline; no .editorconfig in project root
Auto-detectable: ✓ Yes editorconfig phpcs php-cs-fixer
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Low ✓ Auto-fixable Fix: Low Context: File


✓ schema.org compliant