Download the PHP package php-collective/toml without Composer
On this page you can find all versions of the php package php-collective/toml. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download php-collective/toml
More information about php-collective/toml
Files in php-collective/toml
Package toml
Short Description A TOML parser and encoder for PHP with AST access and collected parse errors
License MIT
Homepage https://github.com/php-collective/toml
Informations about the package toml
PHP Toml
A TOML (v1.0 and v1.1) parser and encoder for PHP with AST access and collected parse errors.
Features
- Strict validation for malformed keys, tables, strings, numbers, and datetimes
- Error recovery with multiple error collection for tooling workflows
- Clean architecture with separate Lexer, Parser, and AST
- Zero required extensions (optional php-ds for performance)
- AST access for analysis or editor integrations
- Explicit local date/time/datetime value objects for encoding
Requirements
- PHP 8.2 or higher
Installation
Demo
- Interactive Playground - Full-featured sandbox with all options.
Quick Start
API Reference
Decoding
Encoding
DocumentFormattingMode::SourceAware is lossless for unchanged parsed regions and uses local fallback rules for edited ones. See the Compatibility page for the exact editing contract.
skipNulls lets encode() omit nulls instead of throwing.
Error Handling
The parser provides detailed error messages:
For tooling, use tryParse() to collect all errors:
Supported Syntax
The library currently supports:
- All string types (basic, literal, multi-line)
- Integers (decimal, hex, octal, binary)
- Floats (including inf, nan)
- Booleans
- Dates and times (offset, local datetime, local date, local time)
- Arrays (including multiline arrays and trailing commas)
- Inline tables (including multiline inline tables and trailing commas in TOML 1.1)
- Tables and array of tables
- Dotted keys
See the Support Matrix for current coverage and known gaps.
Versioned behavior is available through TomlVersion and EncoderOptions(version: ...). The default remains TOML 1.1-compatible; use TomlVersion::V10 when you need strict TOML 1.0 parsing or output rules.
For explicit local temporal encoding, use:
PhpCollective\Toml\Value\LocalDatePhpCollective\Toml\Value\LocalTimePhpCollective\Toml\Value\LocalDateTime
Comparison with Other PHP Libraries
| Feature | php-collective/toml | Others |
|---|---|---|
| Error Recovery | Yes | No |
| Multiple Errors | Yes | No |
| AST Access | Yes | Limited/No |
| Round-trip formatting preservation | Partial | Varies |
See Limitations for details.