From 2fbe60d8f7c1fc6a3748e72c35d05aeea06a1e13 Mon Sep 17 00:00:00 2001 From: Youssef Benhssaien Date: Sun, 4 Oct 2020 09:08:31 +0200 Subject: [PATCH] Multiple PHP class per file not allowed Since `AnnotationFileLoader` from `Routing` component parses and loads only one class per file while ignoring others class if declared in the same file, it is good to let know people about this behaviour to not be surprised. --- routing.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/routing.rst b/routing.rst index 117fd75bded..bd256fca9b5 100644 --- a/routing.rst +++ b/routing.rst @@ -46,6 +46,10 @@ following configuration file: This configuration tells Symfony to look for routes defined as annotations in any PHP class stored in the ``src/Controller/`` directory. +.. caution:: + + If you define multiple PHP class per file, only the first declared class can be loaded, try to define one PHP class per file instead, visit `PSR-4 `_ for more details. + Suppose you want to define a route for the ``/blog`` URL in your application. To do so, create a :doc:`controller class ` like the following::