交响乐路线。无法设置注解

Symfony Route. Can't set annotations

我无法理解,如果我用

创建 crud 控制器

bin/console make:crud 所有路由都来自控制器

喜欢

/**
 * @Route("/", name="product_index", methods="GET")
 */

public function index(ProductRepository $productRepository): Response

{
    return $this->render('product/index.html.twig', ['products' => $productRepository->findAll()]);
}

.

如果我用 bin/console make:controller

创建控制器

并自己定义带有注释的控制器它们不起作用

<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use JMS\Serializer\SerializerBuilder;
use Symfony\Component\HttpFoundation\JsonResponse;
use App\Entity\Product;
use App\Repository\ProductRepository;

use JMS\Serializer\SerializationContext;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;

class FirstApiController extends AbstractController
{
  /**
   *
   * @Route("/first_api", name="first_api")
   */
  public function index(ProductRepository $productRepository)
  {
      $data = $productRepository->findAll();
      $serializer = SerializerBuilder::create()->build();
#      $jsonContent = $serializer->serialize($data, 'json');

      $jsonContent = $serializer->serialize($data, 'json', SerializationContext::create()->setGroups(array('details')));


      $response = JsonResponse::fromJsonString($jsonContent);
      return $response;

  }

    /*
     * @Route("/first_api/send", name="send")
     *
     */
    public function send()
    {
        $a = "text";
        return $a;
    }

}

为什么这条路线行不通

@Route("/first_api/send", name="send") ?

在 routes.yaml 中我什么也没写,只是空文件。

我使用了错误的语法!我使用了

/*  <-- the error is here
 * @Route("/first_api/send", name="send")
 *
 */

我需要使用

/**  <-- i nee two "*"
 * @Route("/first_api/send", name="send")
 *
 */
public