itpeopleperformance/apihelper-bundle

Symfony4 Bundle - API 简短快速渲染-2

安装: 5

依赖者: 0

建议者: 0

安全: 0

星级: 0

关注者: 0

分支: 4

类型:symfony-bundle

dev-master 2024-06-03 20:23 UTC

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:更多文档