creads/api2symfony-bundle
最新稳定版本:1.0.0
Composer 安装命令:
composer require creads/api2symfony-bundle
包简介
A Symfony2 bundle to automatically generate controllers from standard API specifications (RAML, Blueprint, Swagger...)
README 文档
README
A Symfony2 bundle to automatically generate controllers from standard API specifications (RAML, Blueprint, Swagger...)
BUT... We only support the following specification formats now:
- RAML
But we'd like to also support:
- Blueprint
- Swagger
This bundle uses the api2symfony library.
Installation
Using composer:
composer require creads/api2symfony-bundle 1.0.*@dev
Register the bundle by updating AppKernel.php:
<?php
// in AppKernel::registerBundles()
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
// ...
$bundles[] = new Creads\Api2SymfonyBundle\Api2SymfonyBundle();
// ...
};
Use case
The bundle provides a command:
app/console.php api2symfony:generate:raml path/to/api.raml Some\\Namespace
Example
php app/console.php api2symfony:generate:raml path/to/api.raml Acme\\DemoBundle
New controller dumped at app/cache/dev/api2symfony/Acme/DemoBundle/1_0_1_alpha/PostsController.php
#%RAML 0.8 title: Api Example version: 1.0.1-alpha /posts: description: Collection of available post resource get: description: Get a list of post post: description: Create a new post /{id}: displayName: Post get: description: Get a single post responses: 200: body: application/json: example: | { "title": "An amazing news" } delete: description: Delete a specific post /comments: description: Collection of available post's comments displayName: Comments get: description: Get list of comment for given post post: description: Comment a post
Generated code:
<?php namespace Acme\DemoBundle\1_0_1_alpha; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; /** * Collection of available post resource * * This is an auto generated class provided by Creads\Api2Symfony PHP library. */ class PostsController extends Controller { /** * Get a list of post * * @Route("/posts", name="get_posts") * @Method({"GET"}) */ public function getPostsAction() { } /** * Create a new post * * @Route("/posts", name="post_posts") * @Method({"POST"}) */ public function postPostsAction() { } /** * Get a single post * * @Route("/posts/{id}", name="get_posts_post") * @Method({"GET"}) */ public function getPostsPostAction($id) { return new Response('{"title": "An amazing news"}', 200, array('Content-Type' => 'application/json')); } /** * Delete a specific post * * @Route("/posts/{id}", name="delete_posts_post") * @Method({"DELETE"}) */ public function deletePostsPostAction($id) { } /** * Get list of comment for given post * * @Route("/posts/{id}/comments", name="get_posts_post_comments") * @Method({"GET"}) */ public function getPostsPostCommentsAction($id) { } /** * Comment a post * * @Route("/posts/{id}/comments", name="post_posts_post_comments") * @Method({"POST"}) */ public function postPostsPostCommentsAction($id) { } }
creads/api2symfony-bundle 适用场景与选型建议
creads/api2symfony-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 570 次下载、GitHub Stars 达 52, 最近一次更新时间为 2014 年 12 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「php」 「api」 「bundle」 「controller」 「converter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 creads/api2symfony-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 creads/api2symfony-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 creads/api2symfony-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The bundle for easy using json-rpc api on your project
A PSR-7 compatible library for making CRUD API endpoints
Bundle Symfony DaplosBundle
Alfabank REST API integration
Biblioteca PHP pura para pagamentos SISP/Vinti4 de Cabo Verde.
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
统计信息
- 总下载量: 570
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 52
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-15