2017 © Pedro Peláez
 

symfony-bundle rest-api-bundle

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

image

matmar10/rest-api-bundle

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  • Friday, July 25, 2014
  • by matmar10
  • Repository
  • 1 Watchers
  • 2 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 3 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

REST API Bundle

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer., (*1)

This bundle uses the popular (JMS Serializer Bundle)[https://github.com/schmittjoh/JMSSerializerBundle] for all serialization., (*2)

JMS Serialize annotation entities are serialized accordingly., (*3)

Installation

Add to your Symfony project composer file:, (*4)

```javascript "require": { "matmar10/rest-api-bundle": "~0.3.2" }, ..., (*5)


Add the bundle to the Kernel and run composer update: ```php // in app/AppKernel.php public function registerBundles() { $bundles = array( ... new Matmar10\Bundle\RestApiBundle\Matmar10RestApiBundle(), ); }

Annotate a controller method; return value will automatically be serialized into JSON or XML:, (*6)

<?php

    namespace Acme\DemoBundle\Controller;

    use Matmar10\Bundle\RestApiBundle\Annotation\Api;
    use Symfony\Bundle\FrameworkBundle\Controller\Controller;

    /**
     * @Api("json")
     */
    class RestApiBundleTestJsonController extends Controller
    {
        public function getArrayAsJsonAction()
        {
            return array(1,2,3,4);
        }

        /**
         * @Api("xml")
         */
        public function getArrayAsXmlAction()
        {
            return array(1,2,3,4);
        }
    }
}

Options

The @Api annotation is used to indicate a controller or method return result should be serialized into a json or xml response (or any other configured serialization type accepted by your JMS Serializer bundle)., (*7)

The value of the @Api annotation indicates the serialization type:, (*8)


@Api("json") public function getPersonAction() { $person = new Person(); $person->setName("Matthew J. Martin"); $person->setAge(28); return $person; } // results in: {"name":"Matthew J. Martin","age":28}

You can also specify a different default status code (for example, when an entity is created):, (*9)


@Api("json", responseCode=201) public function createPersonAction() { $person = new Person(); // process the request, persist the entity, and then return it return $person; }

Exceptions

Exceptions are automatically serialized into the desired serialization format., (*10)

The Versions

25/07 2014

1.0.x-dev

1.0.9999999.9999999-dev

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  Sources   Download

Apache

The Requires

 

The Development Requires

json xml rest api rest symfony jms controller annotation symfony bundle jms serializer bundle marshaling

25/07 2014

1.0.0-rc3

1.0.0.0-RC3

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  Sources   Download

Apache

The Requires

 

The Development Requires

json xml rest api rest symfony jms controller annotation symfony bundle jms serializer bundle marshaling

25/07 2014

1.0.0-rc2

1.0.0.0-RC2

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  Sources   Download

Apache

The Requires

 

The Development Requires

json xml rest api rest symfony jms controller annotation symfony bundle jms serializer bundle marshaling

13/07 2014

1.0.0-rc1

1.0.0.0-RC1

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  Sources   Download

Apache

The Requires

 

The Development Requires

json xml rest api rest symfony jms controller annotation symfony bundle jms serializer bundle marshaling

13/07 2014

dev-symfony-exception-entity

dev-symfony-exception-entity

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  Sources   Download

Apache

The Requires

 

The Development Requires

json xml rest api rest symfony jms controller annotation symfony bundle jms serializer bundle marshaling

09/05 2014

dev-master

9999999-dev

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  Sources   Download

Apache

The Requires

 

The Development Requires

json xml rest api rest symfony jms controller annotation symfony bundle jms serializer bundle marshaling

09/05 2014

0.3.2

0.3.2.0

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  Sources   Download

Apache

The Requires

 

The Development Requires

json xml rest api rest symfony jms controller annotation symfony bundle jms serializer bundle marshaling

15/04 2014

0.2.0

0.2.0.0

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  Sources   Download

Apache

The Requires

 

The Development Requires

json xml rest api rest symfony jms controller annotation symfony bundle jms serializer bundle marshaling

15/04 2014

0.1.0

0.1.0.0

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  Sources   Download

Apache

The Requires

 

The Development Requires

json xml rest api rest symfony jms controller annotation symfony bundle jms serializer bundle marshaling

15/04 2014

0.0.2

0.0.2.0

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  Sources   Download

Apache

The Requires

 

The Development Requires

json xml rest api rest symfony jms controller annotation symfony bundle jms serializer bundle marshaling

08/07 2013

v0.0.1

0.0.1.0

A Symfony Bundle that enables the use of @Api annotation to automatically serialize any return value from any controller using JMS Serializer.

  Sources   Download

Apache

The Requires

 

json xml rest api rest symfony jms controller annotation symfony bundle jms serializer bundle marshaling