Skip to content

Latest commit

 

History

History
216 lines (162 loc) · 4.39 KB

annotations-reference.rst

File metadata and controls

216 lines (162 loc) · 4.39 KB

Full default annotations

Param fetcher

QueryParam

Annotations

use FOS\RestBundle\Controller\Annotations\QueryParam;

/**
 * @QueryParam(
 *   name="",
 *   key=null,
 *   requirements="",
 *   incompatibles={},
 *   default=null,
 *   description="",
 *   strict=false,
 *   map=false,
 *   nullable=false
 * )
 */

Attributes

use FOS\RestBundle\Controller\Annotations\QueryParam;

#[QueryParam(
    name: '',
    key: null,
    requirements: '',
    incompatibles: [],
    default: null,
    description: '',
    strict: false,
    map: false,
    nullable: false
)]

RequestParam

Annotations

use FOS\RestBundle\Controller\Annotations\RequestParam;

/**
 * @RequestParam(
 *   name="",
 *   key=null,
 *   requirements="",
 *   default=null,
 *   description="",
 *   strict=true,
 *   map=false,
 *   nullable=false
 * )
 */

Attributes

use FOS\RestBundle\Controller\Annotations\RequestParam;

#[RequestParam(
    name: '',
    key: null,
    requirements: '',
    default: null,
    description: '',
    strict: true,
    map: false,
    nullable: false
)]

FileParam

Annotations

use FOS\RestBundle\Controller\Annotations\FileParam;

/**
 * @FileParam(
 *   name="",
 *   key=null,
 *   requirements={},
 *   default=null,
 *   description="",
 *   strict=true,
 *   nullable=false,
 *   image=false
 * )
 */

Attributes

use FOS\RestBundle\Controller\Annotations\FileParam;

#[FileParam(
    name: '',
    key: null,
    requirements: [],
    default: null,
    description: '',
    strict: true,
    nullable: false,
    image: false
)]

View

Annotations

use FOS\RestBundle\Controller\Annotations\View;

/**
 * @View(
 *  statusCode=null,
 *  serializerGroups={},
 *  serializerEnableMaxDepthChecks=false
 * )
 */

Attributes

use FOS\RestBundle\Controller\Annotations\View;

#[View(
    statusCode: null,
    serializerGroups: [],
    serializerEnableMaxDepthChecks: false
)]

Routing

Route

RestBundle extends the @Route Symfony annotation. The following are shortcuts to define routes limited to a specific HTTP method: @Delete, @Get, @Head, @Link, @Patch, @Post, @Put, @Unlink, @Lock, @Unlock, @PropFind, @PropPatch, @Move, @Mkcol, @Copy. All of them have the same options as @Route.

Example:

Annotations

// src/Controller/BlogController.php
namespace App\Controller;

use FOS\RestBundle\Controller\AbstractFOSRestController;
use FOS\RestBundle\Controller\Annotations as Rest;

class BlogController extends AbstractFOSRestController
{
    /**
     * @Rest\Get("/blog", name="blog_list")
     */
    public function list()
    {
        // ...
    }
}

Attributes

// src/Controller/BlogController.php
namespace App\Controller;

use FOS\RestBundle\Controller\AbstractFOSRestController;
use FOS\RestBundle\Controller\Annotations as Rest;

class BlogController extends AbstractFOSRestController
{
    #[Rest\Get('/blog', name: 'blog_list')]
    public function list()
    {
        // ...
    }
}