symfonyphpdocumentor2

How to document a controller in symfony?


I'm trying to document my project. I want to document my controller. Before my Action I have:

/**
 * Description: xxx
 * @param parameters of my function Action
 * @return views of the action
 */

The return value here will show:

enter image description here

Why?

Thanks

EDIT:

A standard controller:

public function myControllerAction(Request $request) {

    return $this->render('AppBundle:Default:index.html.twig');
}

Solution

  • The @return annotation expects the data type as a first argument, before the description. In your case you've specified the data type as views which hasn't been included with a use statement, so PHP assumes it belongs to the current namespace and you get \AppBundle\Controllers\views. The return type of a controller must be a Symfony\Component\HttpFoundation\Response. So you want:

    @return \Symfony\Component\HttpFoundation\Response description
    

    or if you already have a use statement for Response:

    @return Response description
    

    In some cases you might want to be more specific if you are always returning a specific subclass of response, like: