yauhenko/rest-bundle
Composer 安装命令:
composer require yauhenko/rest-bundle
包简介
REST and TypeScript generator for Symfony 6
README 文档
README
Step 1: Run
composer req yauhenko/rest-bundle
Step 2: Add to config/routes/annotations.yaml two lines:
rest_bundle: resource: '@RestBundle/config/routes.yaml'
It will register /docs routes
Step 3: Create Types class in src/Types.php:
<?php namespace App; use Yauhenko\RestBundle\TypesInterface; use Yauhenko\RestBundle\Service\TypeScript; class Types implements TypesInterface { public static function registerTypes(TypeScript $ts): void { // register custom types here (optional) $ts->registerTypeOf('TBadge', ['notifications', 'shop']); // register interfaces $ts->registerInterfacesFromDir(__DIR__ . '/Entity'); $ts->registerInterfacesFromDir(__DIR__ . '/Models'); } public static function codePostProcessor(string $code): string { // change generated TypeScript code here (optional) return $code; } }
You can change path to Types class using yauhenko.rest.types_class parameter in config/services.yaml
Step 4 (optional): Configure config/services.yaml:
parameters: # Enable TypeScript generation (default: true) yauhenko.rest.ts_enabled: '%env(bool:API_TS_ENABLED)%' # Types class (default) yauhenko.rest.types_class: 'App\Types' # Path to controllers (default) yauhenko.rest.controllers_dir: '%kernel.project_dir%/src/Controller'
统计信息
- 总下载量: 1.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-03