Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 找不到搜索方法的常量名称_Php_Symfony_Search_Twig_Repository - Fatal编程技术网

Php 找不到搜索方法的常量名称

Php 找不到搜索方法的常量名称,php,symfony,search,twig,repository,Php,Symfony,Search,Twig,Repository,我创建了一个搜索方法,该方法应允许我在细枝表中搜索,添加了自定义存储库方法,该方法允许我通过指定属性查找实体,并在控制器函数中调用它,以及负责搜索函数的脚本,其输入标签在细枝文件中,但我一直得到“[语义错误]在C:\Users\maiez\Projet\config/routes.././src/Controller/(从“C:\Users\maiez\Projet\config/routes/annotations.yaml”导入)中找不到常量名称、方法App\Controller\Inven

我创建了一个搜索方法,该方法应允许我在细枝表中搜索,添加了自定义存储库方法,该方法允许我通过指定属性查找实体,并在控制器函数中调用它,以及负责搜索函数的脚本,其输入标签在细枝文件中,但我一直得到“[语义错误]在C:\Users\maiez\Projet\config/routes.././src/Controller/(从“C:\Users\maiez\Projet\config/routes/annotations.yaml”导入)中找不到常量名称、方法App\Controller\InventaireContesController::searchConte()。请确保已安装并启用批注。 “错误。 请在包含搜索功能的细枝代码中找到以下脚本:

<script>
        $(document).ready(function(){
            $('#search').keyup(function(){
                search_table($(this).val());
            });
            function search_table(value){
                $('#sa tbody').each(function(){
                    var found = 'false';
                    $(this).each(function(){
                        if($(this).text().toLowerCase().indexOf(value.toLowerCase()) >= 0)
                        {
                            found = 'true';
                        }
                    });
                    if(found == 'true')
                    {
                        $(this).show();
                    }
                    else
                    {
                        $(this).hide();
                    }
                });
            }
        });
    </script>
这是控制器方法,似乎不起作用:

 /**
     * @Route ("/invContes/search", name"searchInv")
     * @param Request $request
     * @param NormalizerInterface $Normalizer
     * @return Response
     * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
     */
    public function searchConte(Request $request, NormalizerInterface $Normalizer)
    {
        $repository = $this->getDoctrine()->getRepository(Inventairecontes::class);
        $requestString=$request->get('searchValue');
        $conte=$repository->findContes($requestString);
        $jsonContent=$Normalizer->normalize($conte,'json',['groups'=>'contes']);
        $retour = json_encode($jsonContent);
        return new JsonResponse($jsonContent);
    }
导入和细枝ID是正确的。
提前感谢。

看来您在searchConte方法的路由注释中缺少了一个等号:
名称“searchInv”
。它应该是
name=“searchInv”
错误说明未启用批注,您确定它配置正确吗?看起来更像是您的控制器未正常工作?as控制器已使用@Route注释自动配置。请隔离问题,如果可能,请更新说明。因为我似乎在路线注释中遗漏了等号,我没有注意它。
public function findContes($cnt){
        return $this->createQueryBuilder('contes')
            ->where('contes.titre LIKE :titre')
            ->setParameter('titre', '%'.$cnt.'%')
            ->getQuery()
            ->getResult();
    }
 /**
     * @Route ("/invContes/search", name"searchInv")
     * @param Request $request
     * @param NormalizerInterface $Normalizer
     * @return Response
     * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface
     */
    public function searchConte(Request $request, NormalizerInterface $Normalizer)
    {
        $repository = $this->getDoctrine()->getRepository(Inventairecontes::class);
        $requestString=$request->get('searchValue');
        $conte=$repository->findContes($requestString);
        $jsonContent=$Normalizer->normalize($conte,'json',['groups'=>'contes']);
        $retour = json_encode($jsonContent);
        return new JsonResponse($jsonContent);
    }