1
votes

I am working on the Synfony framework And I am Fresher in Synfony

Framework. I face a problem When I want to run my function I got one error.

Here is my controller:-

<?php 

namespace AppBundle\Controller;

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

class BlogController extends Controller
{
    /**
     * @Route("/blog")
     */
    public function showAction()
    {
      echo "hello friend";
    }
}
?>

my routing.yml file is:-

app:
    resource: "@AppBundle/Controller/"
    type:     annotation    
blog_data:
path:   /blog
defaults: {_controller: AppBundle:blog:show }

Here I created the blog_data my self and I did not mention it any where because i don't know where it is declare.

my routing.dev.yml file is:-

_wdt: resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml" prefix: /_wdt

_profiler: resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml" prefix: /_profiler

_errors: resource: "@TwigBundle/Resources/config/routing/errors.xml" prefix: /_error

_main: resource: routing.yml

when I hit URL:-

http://localhost/mysymfony/web/app_dev.php/blog

I got the error

The definition of "blog_data" in "C:\xampp\htdocs\mysymfony\app/config\routing.yml" must be a YAML array in C:\xampp\htdocs\mysymfony\app/config\routing.yml (which is being imported from "C:\xampp\htdocs\mysymfony\app/config/routing_dev.yml").

How to resolved this problem.

2
seems you are missing spaces before path and defaults definitionsAndrey Mischenko
No, I am sure that i am not missing spaces before path and defaultsshahzad ahmed

2 Answers

1
votes

Actually, your routing.yml file only needs to contain this:

app:
    resource: "@AppBundle/Controller/"
    type:     annotation

Try that and see if it works. Let us know the result.

0
votes

Make 4 spaces before path and defaults.

blog_data:
    path: /blog
    defaults: {_controller: AppBundle:blog:show }