adamwojs/symfony-config-schema-gen
Generate JSON Schema from your Symfony app’s configuration. Adds a config:dump-schema console command to export schemas (JSON by default), with options like schema id, pretty-print, strict mode, and extension whitelisting.
config/packages/*.yaml). Useful for:
.env + config/*.php) is fundamentally different. Integration would require:
ConfigurationNode system with Laravel’s ConfigRepository.Config component standalone (without the full framework) to parse Laravel configs.config() calls into Symfony’s ConfigurationNode format.| Risk Area | Severity (Symfony) | Severity (Laravel) | Mitigation Strategy |
|---|---|---|---|
| Schema Accuracy | Low | High | Validate generated schemas against real configs. |
| Performance Overhead | Low (dev-only) | Medium | Cache schemas; avoid runtime generation in prod. |
| Breaking Changes | Medium | High | Pin to exact versions; test against Symfony 7.x. |
| Dependency Bloat | Low | Medium | Scope to --dev; avoid in production. |
| Maintenance Burden | Low | High | Document custom adapters; isolate from core. |
| Tooling Compatibility | Low | Medium | Ensure IDE plugins support custom schemas. |
Symfony Projects:
config/packages/)? If not, is the value proposition (schema generation) worth the effort?Symfony\Component\Config\Loader\LoaderInterface) or just documentation?config:dump-reference) that overlap with this package’s functionality?Laravel Projects:
.env files, generating OpenAPI specs from config, or IDE support?)JsonSchema PHP library) be simpler than integrating this package?Cross-Stack:
| Stack Component | Fit Level | Notes |
|---|---|---|
| Symfony Framework | High | Native support; minimal setup. |
| Symfony Components | Medium | Requires standalone Config component; no full framework needed. |
| Laravel Core | Low | No native fit; requires custom adapters or proxy layers. |
| Laravel + Symfony | Medium | Feasible if using Symfony components (e.g., API Platform, Mercure). |
| PHP CLI Tools | High | Works anywhere Composer runs (e.g., for schema generation in CI/CD). |
| IDE/Editor Plugins | High | Output schemas can be used in PHPStorm/VSCode for autocompletion. |
composer require adamwojs/symfony-config-schema-gen --dev
// config/bundles.php
AdamWojs\SymfonyConfigGenBundle\SymfonyConfigSchemaGenBundle::class => ['dev' => true],
php bin/console config:dump-schema > schema.json
Configuration component for validation.Option A: Symfony Component Standalone (High Risk)
Config component:
composer require symfony/config --dev
ConfigurationNode.SymfonyConfigSchemaGenBundle in a dev-only command.Option B: Custom Schema Generator (Recommended for Laravel)
justinrainbow/json-schema to generate schemas from Laravel’s config() structure.// app/Console/Commands/GenerateConfigSchema.php
use JustinRainbowJsonSchema\Validator;
use Symfony\Component\Console\Command\Command;
class GenerateConfigSchema extends Command {
protected function execute(InputInterface $input, OutputInterface $output) {
$config = config()->all();
$schema = $this->generateSchemaFromArray($config);
file_put_contents(base_path('schema.json'), json_encode($schema, JSON_PRETTY_PRINT));
}
private function generateSchemaFromArray(array $data): array {
// Implement logic to infer schema from $data
return [
'type' => 'object',
'properties' => $this->mapConfigToSchema($data),
];
}
}
Option C: Hybrid Approach (For Laravel + Symfony)
symfony-config-schema-gen for those files only.| Aspect | Symfony Projects | Laravel Projects |
|---|---|---|
| Bundle Updates | Low (dev-only, isolated) | Medium (custom adapters may break) |
| Schema Updates | Medium (config changes = schema changes) | High (custom logic may need updates) |
| Dependency Risks | Low (Symfony ecosystem) | High (Symfony components may diverge) |
| Long-Term Viability | High (Symfony LTS support) | Low (Laravel-specific solutions may emerge) |
How can I help you explore Laravel packages today?