0

İ am new to Symfony. I have a problem. I created a new bundle. I made necessary settings. But I get the following error.

I want to open index.html.twig under BlogBundle/Defaults.

Unable to find template "BlogBundle:Default:index.html.twig" (looked into: C:\xampp\htdocs\deneme\app/Resources/views, C:\xampp\htdocs\deneme\vendor\symfony\symfony\src\Symfony\Bridge\Twig/Resources/views/Form).

DefaultController:

<?php

namespace BlogBundle\Controller;

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

class DefaultController extends Controller
{
    /**
     * @Route("/")
     */
    public function indexAction()
    {
        return $this->render('BlogBundle:Default:index.html.twig');
    }
}

routing:

    blog:
    resource: "@BlogBundle/Controller/"
    type:     annotation
    prefix:   /

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

composer:

"name": "user/my_project",
"license": "proprietary",
"type": "project",
"autoload": {
    "psr-4": {
        "AppBundle\\": "src/AppBundle",
        "BlogBundle\\": "src/BlogBundle"
    },
    "classmap": [
        "app/AppKernel.php",
        "app/AppCache.php"
    ]
},

Please help me. Thanks.

ozahorulia
  • 9,798
  • 8
  • 48
  • 72
Bilgi Emek
  • 1
  • 1
  • 1
  • C:\xampp\htdocs\deneme\vendor\symfony\symfony\src\Symfony\Bridge\Twig/Resources/views/Form has two different types of slashes – G_V Feb 07 '18 at 13:03
  • The bundle:dir:name format has pretty much gone away. It is possible to still use it with the correct configuration but it is recommended to use twig namespaces so: '@BlogBundle\Default\index.html.twig' should work. You can use "bin/console debug:twig" to see where the BlogBundle twig namespace is mapped to. – Cerad Feb 07 '18 at 14:33
  • 1
    Basically a dup of: https://stackoverflow.com/questions/47832977/symfony-3-4-use-view-inside-my-bundle/47835716#47835716 – Cerad Feb 07 '18 at 14:35
  • Possible duplicate of [Symfony 3.4 Use view inside my bundle](https://stackoverflow.com/questions/47832977/symfony-3-4-use-view-inside-my-bundle) – Mike Doe Feb 07 '18 at 21:45

1 Answers1

0

you need to have an index.html.twig file under one of the followings trees:

  • app/resources/views/your_controller_name(Default)/index.html.twig or
  • src/your_bundle/resources/views/your_controller_name(Default)/index.html.twig
Themer
  • 584
  • 4
  • 9