This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
DcfParser (makowskid/dcfparser) is a minimal PHP library for parsing Debian Control Files (DCF format). It has zero production dependencies and optional Laravel integration via service provider auto-discovery.
- PHP requirement:
^8.2 - Namespace:
makowskid\DcfParser\
# Run tests
composer test
# Install dependencies
composer install
# Static analysis (PHPStan level 8)
composer analyse
# Code style check
composer cs-check
# Code style fix
composer cs-fixThe library consists of four classes:
-
src/DcfParser.php- The core parser. Public methods:parseFile(string $path): array— reads a DCF file, returns first stanza as associative array with lowercased keysparseFileAll(string $path): array— reads a DCF file, returns all stanzasparseString(string $content): array— parses DCF string, returns first stanzaparseStringAll(string $content): array— parses DCF string, returns all stanzas
Internally uses
file_get_contentsand a sharedparseLines()method. Handles multi-line continuation values, comment lines (#), Windows line endings, and blank-line stanza separators. ThrowsDcfParserExceptionon errors. -
src/Exception/DcfParserException.php- Runtime exception for parse/file errors. -
src/ServiceProviders/DcfParserServiceProvider.php- Laravel service provider. RegistersDcfParseras a singleton bound to the'dcfparser'key. Auto-discovered by Laravel viacomposer.jsonextras. -
src/Facades/DcfParserFacade.php- Laravel facade accessor for'dcfparser'.
Reference: https://www.debian.org/doc/debian-policy/ch-controlfields.html
- Key-value pairs separated by first
:on the line - Continuation lines start with whitespace and append to the previous key's value
- Keys are case-insensitive (normalized to lowercase in output)
- Blank lines separate stanzas (paragraphs)
- Comment lines starting with
#are skipped
PHPUnit 12 with comprehensive tests in tests/DcfParserTest.php. Covers single/multi stanza parsing, error cases, edge cases (comments, Windows line endings, empty values, colons in values), and file I/O.