internal/toml
TOML 1.0.0/1.1.0 parser and encoder for PHP 8.1+. Parse TOML files straight into PHP arrays or encode arrays back to TOML, with support for tables, arrays of tables, and standard value types. A small, dependency-free tool for config files.
Toml::parse() → Document → (string) flow supports format-preserving config mutation. This unlocks product features like config:set, environment editors, and "edit this file without reformatting it" UX, which array-only parsers cannot do cleanly.JsonSerializable objects to TOML supports generators for CI templates, Kubernetes/Terraform-adjacent manifests, and fixture authoring — useful for internal developer tooling more than end-user runtime.Consider it when:
inf/nan, local time with optional seconds, multiline inline tables).ConfigReader/ConfigWriter interface) so migration to another implementation is a one-file change.Look elsewhere when:
Adoption guardrail: pilot in one non-critical service, pin an exact version, and add a parse-failure test suite covering your real config surface before wider rollout.
For executives:
We're evaluating a small library that lets our PHP services read and write TOML configuration files with full TOML 1.1 support and a clean, modern API. The upside is developer ergonomics: TOML is readable, strongly typed, and common in infrastructure tooling (Kubernetes, Terraform ecosystems, Rust), so adopting it can simplify our config story and reduce hand-rolled parsing code. The honest caveat is maturity: it has very low adoption (5 stars, no downstream dependents) and a single primary maintainer. My recommendation is a bounded pilot behind an internal interface, not a platform-wide standard — that captures the ergonomic benefit while keeping our switching cost at roughly one adapter file if the project stalls. This is a low-cost experiment with a capped blast radius, not a strategic bet.
For engineering:
This gives us three things we don't have today: spec-compliant TOML 1.0/1.1 parsing, encoding from PHP arrays and
JsonSerializableobjects, and an AST with format-preserving round-trips (e.g.,magic = 0xDEADBEEFsurvives a parse/emit cycle). The API is three calls:Toml::parse(),Toml::parseToArray(),Toml::encode(). That makes it a good fit for config readers and for CLI generators where we produce TOML from PHP data.Trade-offs to plan around: low adoption and a single maintainer mean we must pin versions and own the integration glue (no Laravel/Symfony package exists). There is no config-caching story out of the box, so if we replace framework config files we own loader precedence and cache invalidation. Also note the encoder targets TOML 1.0-compatible output for interoperability even though the parser accepts 1.1 — don't assume 1.1-only syntax survives a round-trip through encode.
Proposal: wrap it behind a
ConfigReader/ConfigWriterinterface, pilot on one service, add golden-file tests for our real configs, and revisit adoption breadth after a release cycle. If it proves out, we get a clean TOML story; if not, the adapter is our exit.
How can I help you explore Laravel packages today?