简体   繁体   English

Symfony 2:加载 URI 时找不到资源错误 - 404 错误

[英]Symfony 2: Resource not found error while loading URI - 404 error

Below are details:以下是详细信息:

File Structure文件结构在此处输入图片说明

routing.yml路由.yml

app_api:
#     resource: "@TemplateManager/Bundle/DocumentGeneratorBundle/Controller/API"
     resource: "@TemplateManagerDocumentGeneratorBundle/Controller/API"
     type:     annotation

routing_dev.yml路由_dev.yml

app_api:
     resource: "@TemplateManager/Bundle/DocumentGeneratorBundle/Controller/API"
#     resource: "@TemplateManagerDocumentGeneratorBundle/Controller/API"
     type:     annotation

App Kernel应用内核

$bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new TemplateManager\Bundle\DocumentGeneratorBundle\TemplateManagerDocumentGeneratorBundle(),
            new FOS\UserBundle\FOSUserBundle(),
        );

Controller控制器

<?php
namespace TemplateManager\Bundle\DocumentGeneratorBundle\Controller\API;

use Symfony\Component\HttpFoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;



class ClientController
{
    /**
     * @Route("api/clients")
     * @Method("GET")
     */

    public function allAction()
    {
        return new Response("Lets Do this");
    }
}

DocumentGeneratorBundle文档生成器包

namespace TemplateManager\Bundle\DocumentGeneratorBundle;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use TemplateManager\Bundle\DocumentGeneratorBundle\DependencyInjection\Compiler\OverrideServiceCompilerPass;

class TemplateManagerDocumentGeneratorBundle extends Bundle
{
}

App Console Error for Routing路由的应用程序控制台错误

 php app/console router:debug
[Symfony\Component\Config\Exception\FileLoaderLoadException]                                                                                                                      
  Cannot load resource "@TemplateManager/Bundle/DocumentGeneratorBundle/Controller/API". Make sure the "TemplateManager" bundle is correctly registered and loaded in the applicat  
  ion kernel class. 

Error while accessing URI访问 URI 时出错

TwigBundle:Exception:error404.html.twig TwigBundle:异常:error404.html.twig

There is no need to duplicate this config into routing.yml and routing_dev.yml无需将此配置复制到 routing.yml 和 routing_dev.yml 中

This line: resource: "@TemplateManagerDocumentGeneratorBundle/Controller/API" should be correct.这一行: resource: "@TemplateManagerDocumentGeneratorBundle/Controller/API"应该是正确的。 Delete commented line from routing.yml , and delete app_api entry from routing_dev.yml .routing.yml删除注释行,从routing_dev.yml删除app_api条目。

If it isn't still correct, please post content of ...Bundle.php file inside src/TemplateManager/Bundle/DocumentGeneratorBundle/ dir.如果仍然不正确,请将...Bundle.php文件的内容发布到src/TemplateManager/Bundle/DocumentGeneratorBundle/目录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM