scedel/codegen-symfony
最新稳定版本:0.2.1
Composer 安装命令:
composer require scedel/codegen-symfony
包简介
Symfony class generator for Scedel schemas
README 文档
README
Generates Symfony-ready PHP classes from Scedel schemas (SchemaRepository) with symfony/validator attributes.
RFC support
What it does
- Builds DTO-like classes for custom record-like Scedel types.
- Maps many builtin Scedel constraints to Symfony
Assert\*attributes. - Understands control annotations under
php.*andphp.symfony.*. - Returns warnings for unsupported/ambiguous constructs.
API usage
use Scedel\Codegen\Symfony\SymfonyCodeGenerator; use Scedel\Codegen\Symfony\SymfonyCodegenOptions; $generator = new SymfonyCodeGenerator(); $result = $generator->generate( $repository, new SymfonyCodegenOptions( outputDir: 'src/Dto/Scedel', defaultNamespace: 'App\\Dto\\Scedel', ), ); foreach ($result->files as $file) { file_put_contents($file->path, $file->contents); }
CLI
php scedel-codegen-symfony/bin/generate-symfony.php \ --output-dir src/Dto/Scedel \ --namespace App\\Dto\\Scedel \ /absolute/path/schema.scedel
Supported control annotations
Type-level:
@php.codegen.namespace = "App\\Dto"@php.codegen.dir = "src/Dto"@php.codegen.class = "PostDto"@php.codegen.file = "PostDto.php"@php.symfony.ignore = "true"@php.symfony.validation.groups = "create,update"@php.symfony.constraint... = "..."
Field-level:
@php.codegen.property = "authorEmail"@php.symfony.ignore = "true"@php.symfony.type = "?string"@php.symfony.not_blank = "true"@php.symfony.validation.groups = "create"@php.symfony.constraint... = "..."
Custom constraint injection:
@php.symfony.constraint = "Length(min: 3, max: 255)"@php.symfony.constraint.primary = "NotBlank"@php.symfony.constraint.secondary = "Regex(pattern: '/^[A-Z]+$/')"
If the value does not start with Assert\, generator prepends it automatically.
Notes
- Non-record-like custom types are skipped with warnings.
- Inline record fields are generated as
arraywith warnings. - Conditional types are simplified (best-effort mapping + warnings).
- Unsupported Scedel validators/arguments are reported in warnings.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-18