0

I am new to symfony2. I am creating a simple page for "Hello {Name}" and using WAMP. and my routing.yml is as follows

projectnew_bundle:
    resource: "@projectnew_bundle/Resources/config/routing.yml"
    type:     annotation
    prefix:   /start

and my @projectnew_bundle/Resources/config/routing.yml is as follows (projectnew_bundle is the namespace for \project\new_bundle in src folder) :

projectnew_bundle_hello:
    pattern:  start/hello/{name}
    defaults: { _controller: projectnew_bundle:Start:hello }

I have also registered the bundle projectnew_bundle in AppKernel.php using "new project\new_bundle\projectnew_bundle()" syntax. My \src\project\new_bundle\projectnew_bundle.php is as follows:

<?php

namespace project\new_bundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class projectnew_bundle extends Bundle
{
}

But, when I try to load the following URL : "http://localhost/symfony_project/Symfony/web/app_dev.php/start/hello/Riten" , it gives the 500 internal server error:

Cannot load resource "@projectnew_bundle/Resources/config/routing.yml". Make sure the "projectnew_bundle/Resources/config/routing.yml" bundle is correctly registered and loaded in the application kernel class.

4
  • To be sure, did you clear the cache (app/console cache:clear -env=dev) Commented Oct 19, 2012 at 13:19
  • I didn't use console.. But, I have cleared the Symfony/app/cache folder manually.. Commented Oct 20, 2012 at 6:44
  • Please guys give me the solution to fix the problem Commented Oct 20, 2012 at 11:01
  • And btw. start using CamelCase not underscore_case Commented May 17, 2015 at 10:04

2 Answers 2

3

Try removing type: annotation from routing.yml

EDIT:

Your app/cofig/routing.yml has

projectnew_bundle:
    resource: "@projectnew_bundle/Resources/config/routing.yml"
    prefix:   /start

*Note: I removed type: annotation

So you set prefix /start on any route included in projectnew_bundle/Resources/config/routing.yml

Then your @projectnew_bundle/Resources/config/routing.yml has:

projectnew_bundle_hello:
    pattern:  start/hello/{name}
    defaults: { _controller: projectnew_bundle:Start:hello }

which creates the route projectnew_bundle_hello with the pattern start/hello/{name} adding the prefix from app/config/routing.yml your final route is /startstart/hello/{name} and not /start/hello/{name} as you are expecting.

If you want your expected route to work you can remove start from @projectnew_bundle/Resources/config/routing.yml.

The command php app/console router:debug will show you what your routes actually are.

Sign up to request clarification or add additional context in comments.

2 Comments

Now, I removed the type: annotation from routing.yml ... and it is now showing 404 not found error: 'No route found for "GET /start/hello/Riten" '.. So, what should I do now to solve this??
Thanks @Daniel.. You really helped me to solve this problem.. :)
1

If you change to type: annotation you have to change the resource path to the controller path.

projectnew_bundle:
resource: "@projectnew_bundle/Controller"
type:     annotation
prefix:   /start

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.