-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Context
Related to horde/hordectl#2 - hordectl needs to provide interactive configuration with hints about required/optional fields.
Currently, configuration validation and schema information lives in:
- Horde application XML config files (
horde/base/config/*.xml) - Duplicated in web UI forms
- Potentially duplicated in CLI (hordectl)
Problem
PhpConfigFile is excellent for reading/writing PHP config files while preserving structure, but it doesn't provide:
- Schema/metadata about configuration structure
- Validation rules
- Required vs optional field information
- Type information
- Help text/descriptions
This leads to duplication of validation logic across web UI and CLI tools.
Proposed Enhancement
Add optional schema support to PhpConfigFile:
Option 1: Schema as separate object
$schema = new ConfigSchema();
$schema->defineField('sql.phptype', [
'type' => 'string',
'required' => true,
'enum' => ['mysql', 'pgsql', 'sqlite'],
'help' => 'Database type'
]);
$file = new PhpConfigFile('config.php', schema: $schema);
$file->validate(); // Check against schemaOption 2: Schema from external source
$schema = ConfigSchema::fromXml('horde/config/conf.xml');
$file = new PhpConfigFile('config.php', schema: $schema);Option 3: Schema embedded in config file
Use PHP 8 attributes or docblocks in generated config:
// Auto-generated from schema
class HordeConfig {
#[Required, Type('string'), Enum(['mysql', 'pgsql'])]
public string $sql_phptype;
}Use Cases
- CLI validation - hordectl can validate config before saving
- Interactive prompts - Show required vs optional fields
- Documentation - Generate config docs from schema
- Migration - Validate config after upgrades
- Type safety - Catch config errors early
Long-term Vision
See horde/hordectl#2 for broader architectural discussion:
- Migrate from XML-based schema to PHP class definitions
- Use PHP attributes for metadata
- Single source of truth for validation
- XML as output format for backwards compatibility
Questions
- Should PhpConfigFile handle validation, or just provide schema access?
- Should this be a separate package (horde/config-schema)?
- How to handle backwards compatibility with existing XML schemas?
- Performance implications of schema validation?
Related Issues
- Interactive mode should provide hints about missing required attributes per driver hordectl#2 - Interactive mode hints
- Future horde/core issue - Schema migration plan
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request