internal/toml
PHP 8.1+ TOML 1.0.0/1.1.0 parser and encoder. Parse TOML strings/files into PHP arrays or an AST, modify documents, and serialize back to TOML with round-trip support.
config.php arrays or JSON/YAML). TOML’s explicit syntax (e.g., tables, arrays) aligns with Laravel’s service container and environment management.config.toml files).ports = [8000, 0x1F40]).enabled = true with explicit booleans).dev.toml, prod.toml with shared schemas).spatie/toml if critical)..env files? (TOML is better for structured data; .env is still needed for secrets.)config() helper? (Need a service provider to auto-load TOML files.)Toml class to Laravel’s container for dependency injection.config.php arrays with TOML files in config/ directory.php artisan config:toml).ParameterBag or YamlFileLoader replacements.database.php) with database.toml.// app/Providers/TomlConfigServiceProvider.php
public function register() {
$toml = new \Internal\Toml\Toml();
$config = $toml->parseToArray(file_get_contents(config_path('toml.php')));
$this->app->instance('config.toml', $config);
}
toml.php config loader alongside existing JSON/YAML configs.// config('database.connection') // Works for TOML/JSON/YAML
php artisan config:convert json_to_toml
config:cache command..env for secrets)..env (e.g., config('database.host') falls back to .env).JsonSerializable for custom encoding.DateTimeImmutable support for dates.0xDEADBEEF stays hex).config.php).README.md for Laravel-specific usage (e.g., config loading).Toml::encode() + Toml::parseToArray() to verify data integrity.spatie/toml.spatie/toml has more stars but lacks encoding.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Invalid TOML syntax | App crashes on config load | Use try-catch with Toml::parse(). |
| TOML 1.1 feature not supported | Configs break in edge cases | Test with TOML 1.1 validation tools. |
| PHP 8.1+ requirement | Blocks legacy Laravel apps | Use spatie/toml for PHP 7.4+ (if needed). |
| Missing keys in TOML | Runtime errors | Validate TOML against a schema. |
| Round-trip data loss | Hex numbers → decimals | Verify with Toml::encode() + parse(). |
README.md.TomlServiceProvider for new projects.php artisan toml:validate for config checks.How can I help you explore Laravel packages today?