1

I have created simple controller, set routing and everything works, until I add the routing for the third link. Then I got an error

Cannot import resource "C:\xampp\htdocs\Symfony\src\Acme\Bundle\WebBundle/Resources/config/routing.yml" from "C:/xampp/htdocs/Symfony/app/config\routing.yml".

DefaultController.php:

<?php

namespace Acme\Bundle\WebBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class DefaultController extends Controller
{
public function indexAction()
{
    return $this->render('AcmeWebBundle:Default:index.html.twig');
}


//* find a ride *//

public function findAction()
{

    return $this->render('AcmeWebBundle:Default:find.html.twig');

}

//*book a ride *//

public function bookAction()
 {

    return $this->render('AcmeWebBundle:Default:book.html.twig');
  }
}

This is part of the master.html.twig where is the simple navigation.

  ...
   <div id="left1"><a href="{{ path('acme_web_homepage') }}"><strong>Home</strong></a>
     </div>
     <div id="left2">
     </div>
     <div id="left3"><a href="{{ path('find') }}"><strong>Find a ride</strong></a>
     </div>
     <div id="left4">
     </div>
     <div id="left5"><a href="{{ path('book') }}"><strong>Book a ride</strong></a>
     </div>

and the routing.yml file

acme_web_homepage:
    pattern:  /home
    defaults: { _controller: AcmeWebBundle:Default:index }

find:
    pattern: /find
    defaults: { _controller: AcmeWebBundle:Default:find }
book:
    pattern: /book
    defaults: { _controller: AcmeWebBundle:Default:book }

If I remove the route for the book path everything works fine. Where am I wrong?

3 Answers 3

4

Yaml is based on indentation. You must indent all properties of book with some spaces (I recommend 4 spaces):

book:
    pattern: /book
    defaults: { _controller: AcmeWebBundle:Default:book }

More information about the Yaml Format in the documentation.

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

1 Comment

Thank you for your answer Wouter. However, i have done your suggestion but still no luck :/
2

The yml files must be indented by 4 spaces.

book:
    pattern: /book
    defaults: { _controller: AcmeWebBundle:Default:book }

Comments

0

Finaly i figure out what was the problem:

I have left space with pressing the tab button. No matter how weird this will sound i replace that with 4 spaces like @Wouter suggested and everything works fine.

Next time forget the tab, when working with yml files.

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.