sopinet/apihelper-bundle

Symfony2 Bundle - 简短快速渲染API

安装: 523

依赖: 1

建议者: 0

安全: 0

星星: 0

关注者: 7

分支: 4

开放问题: 2

类型:symfony-bundle

2.0 2017-04-23 14:46 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:58:26 UTC


README

Symfony2 Bundle - 简短快速渲染API

安装

Composer

在终端中写入

composer require sopinet/apihelper-bundle "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有其他Bundle的依赖关系

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();

待办:更多文档