2017 © Pedro Peláez
 

symfony-bundle api-bundle

Ruwork API Bundle

image

ruwork/api-bundle

Ruwork API Bundle

  • Tuesday, July 17, 2018
  • by RUVENTS
  • Repository
  • 3 Watchers
  • 0 Stars
  • 356 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 1 % Grown

The README.md

Ruwork API Bundle

Routing

_api:
    resource: '@AppBundle/Controller/Api/'
    type:     annotation
    prefix:   /api
    defaults:
        _format: json
        # _ruwork_api attribute enables api listeners for this route
        _ruwork_api: true

Controller

<?php

namespace AppBundle\Controller\Api;

use Ruwork\ApiBundle\Annotations as Api;
use Ruwork\ApiBundle\Controller\AbstractApiController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

/**
 * @Route("/test")
 */
class TestController extends AbstractApiController
{
    /**
     * @Method("GET")
     * @Route("")
     * @Api\Doc("Test method", requiresAuth=true, description="

Test method description., (*1)

", * params={@Api\Param("id", required=true, format="int", description="

Description., (*2)

")}, * block="test", displayRoles={"ROLE_API_TEST"} * ) */ public function indexAction() { return ['test' => 1]; } }

Templating

twig:
    paths:
        "%kernel.project_dir%/vendor/ruwork/api-bundle/Resources/views": RuworkApiOriginal
{# app/Resources/RuworkApiBundle/views/docs.html.twig #}

{% extends '@RuworkApiOriginal/docs.html.twig' %}

{% block title 'Website API' %}

{% block test %}
    Override the whole method card
{% endblock %}

{% block test_description %}
    Override method description
{% endblock %}

{% block test_param_id_description %}
    Override parameter description
{% endblock %}

The Versions