Search code examples
phpsymfonycomments

Why Symfony framework is able to use comment out area to identify entity file?


Could anyone tell me how does Symfony framework use comment out the area to do something? I'm a quite junior developer, before using Symfony, I have never seen any syntax like this.

/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer", options={"unsigned":true})
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="IDENTITY")
 */

or

/**
 *
 * @Route("/products/add_favorite/{id}", name="product_add_favorite", requirements={"id" = "\d+"})
 */

I know /*......*/ is an area to comment out and used to define a function before it. But why it comes functionality here, Hope you can tell me where do I miss.


Solution

  • In Symfony you have the option to use annotation, xml or yml configuration.' By default the annotation is used, that's what you see in this case. Personally I think it's a nice way to get your configuration close to the actual code which it affects to.

    More info, see this blog