ovrflo/api-platform-typescript-generator-bundle
Composer 安装命令:
composer require ovrflo/api-platform-typescript-generator-bundle
包简介
A Symfony bundle to generate TypeScript types for your API Platform project. It can generate models, endpoints, routes and a bit more.
README 文档
README
This bundle exposes a command to generate typescript interfaces for your API platform resources. It can generate interfaces for models, enums, API endpoints, app routes and more.
Why?
When bootstrapping a new project with API platform, I found myself writing a lot of boilerplate code to get the frontend to work with the API. Looking for a solution for generating glue code for the frontend, I couldn't find anything to express the breadth of metadata that API platform exposes. Another factor was the fact that existing solutions tend to be focused on boostraping the project, with limited use after that.
This bundle aims to generate the glue code for the frontend, and keep it up to date with the API platform metadata while you develop your app.
Installation
composer require --dev ovrflo/api-platform-typescript-generator-bundle:dev-main
Then, add to config/bundles.php:
return [ // ... Ovrflo\ApiPlatformTypescriptGeneratorBundle\OvrfloApiPlatformTypescriptGeneratorBundle::class => ['dev' => true], ];
Configuration
# config/packages/ovrflo_api_platform_typescript_generator.yaml when@dev: ovrflo_api_platform_typescript_generator: output_dir: '%kernel.project_dir%/assets/api' model_metadata: namespaces: ['App\Entity']
Usage
bin/console ovrflo:api-platform:typescript:generate
# or the watcher (requires nodejs and chokidar)
node ./vendor/.bin/generate_api_types_watch.js
The generated endpoint files also rely on an ApiMethods.ts file existing in your project
and exporting a few functions that are used to make the API calls.
Output --- When running the command, it will generate a bunch of files in the `config.output_dir` (default `assets/api`) directory. ```bash <output_dir>/interfaces/ApiTypes.ts # common interfaces for API platform <output_dir>/interfaces/Enum.ts # enum types <output_dir>/interfaces/<Entity|Resource>.ts # interfaces for the different entities discovered <output_dir>/endpoint/<Resource>.ts
ovrflo/api-platform-typescript-generator-bundle 适用场景与选型建议
ovrflo/api-platform-typescript-generator-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 105 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ovrflo/api-platform-typescript-generator-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ovrflo/api-platform-typescript-generator-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 105
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-11-11