itpeopleperformance / apihelper-bundle
Symfony4 Bundle - API 简短快速渲染-2
dev-master
2024-06-03 20:23 UTC
Requires
- php: >=7.1
- friendsofsymfony/rest-bundle: ^3.0
- jms/serializer-bundle: *
This package is not auto-updated.
Last update: 2024-09-26 04:17:37 UTC
README
Symfony2 Bundle - API 简短快速渲染
安装
Composer
在终端中写入
composer require sopinet/apihelper-bundle-2 "1.0"
AppKernel
启用 Bundle,添加到 Kernel
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
// ...
public function registerBundles()
{
$bundles = array(
// ...
new Sopinet\ApiHelperBundle\SopinetApiHelperBundle(),
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
);
// ...
}
}
添加到配置
配置 FOSRestAPI
fos_rest:
routing_loader:
default_format: json
Bundle 依赖
记住,这个 Bundle 有其他 Bundles 的依赖
https://github.com/schmittjoh/JMSSerializerBundle
https://github.com/FriendsOfSymfony/FOSRestBundle
这些 Bundle 的配置信息已包含。如果您在配置时遇到任何问题,请查阅这些 Bundle 的官方文档。
使用
use SopinetApiHelperBundle\Services\ApiHelper;
$apiHelper = $this->get('sopinet_apihelperbundle_apihelper');
...
return $apiHelper->responseOk();
TODO:更多文档