Volatil3 Volatil3 - 2 months ago 18
PHP Question

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

Below are details:

File Structure
enter image description here

routing.yml

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


routing_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


TwigBundle:Exception:error404.html.twig

Answer

There is no need to duplicate this config into routing.yml and routing_dev.yml

This line: resource: "@TemplateManagerDocumentGeneratorBundle/Controller/API" should be correct. Delete commented line from routing.yml, and delete app_api entry from routing_dev.yml.

If it isn't still correct, please post content of ...Bundle.php file inside src/TemplateManager/Bundle/DocumentGeneratorBundle/ dir.