Skip to content

Controller as a service when using annotated routing #1731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cookbook/controller/service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ you'll interact directly with the services that you need. Fortunately, this is
usually pretty easy and the base ``Controller`` class itself is a great source
on how to perform many common tasks.

When using annotations to setup routing when using a controller defined as a
service, you need to specify your service as follows::

/**
* @Route("/blog", service="my_bundle.annot_controller")
* @Cache(expires="tomorrow")
*/
class AnnotController extends Controller
{
}

In this example, ``my_bundle.annot_controller`` should be the id of the
``AnnotController`` instance defined in the service container. This is
documented in the :doc:`bundles/SensioFrameworkExtraBundle/annotations/routing`
chapter.

Read more

.. note::

Specifying a controller as a service takes a little bit more work. The
Expand Down