2016-08-16 204 views
0

我的网站的工作,我有配置我的网站督促,并把服务器上的文件,当我去的网站:http://tolkienbestiaire.esy.es/web/tolkienSymfony3无法找到本地主机模板督促

我有一个错误:

Unable to find template "TolkienBestiaireBundle:Bestiaire:index.html.twig" (looked into: /home/u493202215/public_html/app/Resources/views, /home/u493202215/public_html/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form). 

我不明白为什么在“app/Resources/views”中搜查,因为真实的方法是../public_html/src/Tolkien/BestiaireBundle/Resources/views

当我去http://tolkienbestiaire.esy.es/web/login错误是

Warning: file_get_contents(C:\wamp64\www\tolkien-bestiaire\app/Resources/FOSUserBundle/views/Security/login.html.twig): failed to open stream: No such file or directory 

C:\wamp64\www\tolkien-bestiaire\...是我的本地目录,服务器目录中的public_html。

我在windows上工作,是一个unix服务器。

回答

-1

我清空缓存,现在我们可以去http://tolkienbestiaire.esy.es/web/loginhttp://tolkienbestiaire.esy.es/web/registerhttp://tolkienbestiaire.esy.es/web/about,大约是在另一个包(

SRC

| -Tolkien

| | -BestiaireBundle(http://tolkienbestiaire.esy.es/web/tolkien,家页面等...)

|||CoreBundle(http://tolkienbestiaire.esy.es/web/about,主布局 )

应用/配置/ routing.yml中:

tolkien_cms: 
    resource: "@TolkienCmsBundle/Controller/" 
    type:  annotation 
    prefix: /

tolkien_bestiaire: 
    resource: "@TolkienBestiaireBundle/Resources/config/routing.yml" 
    prefix: /tolkien 

tolkien_core: 
    resource: "@TolkienCoreBundle/Resources/config/routing.yml" 

fos_user_security: 
    resource: "@FOSUserBundle/Resources/config/routing/security.xml" 

fos_user_profile: 
    resource: "@FOSUserBundle/Resources/config/routing/profile.xml" 
    prefix: /profile 

fos_user_register: 
    resource: "@FOSUserBundle/Resources/config/routing/registration.xml" 
    prefix: /register 

fos_user_resetting: 
    resource: "@FOSUserBundle/Resources/config/routing/resetting.xml" 
    prefix: /resetting 

fos_user_change_password: 
    resource: "@FOSUserBundle/Resources/config/routing/change_password.xml" 
    prefix: /profile 

SRC /托尔金/ BestiaireBundle/BestiaireController.php:

<?php 
namespace Tolkien\BestiaireBundle\Controller; 

use Symfony\Component\Yaml\Tests\A; 
use Tolkien\BestiaireBundle\Entity\Bestiaire; 
use Tolkien\BestiaireBundle\Event\MessagePostEvent; 
use Tolkien\BestiaireBundle\Event\TolkienEvents; 
use Tolkien\BestiaireBundle\Form\BestiaireEditType; 
use Tolkien\BestiaireBundle\Form\BestiaireType; 
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 
use Symfony\Bundle\FrameworkBundle\Controller\Controller; 
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; 
use Symfony\Component\HttpFoundation\Request; 
use Symfony\Component\HttpFoundation\Response; 
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; 

class BestiaireController extends Controller 
{ 
    public function indexAction($page) 
    { 
     $nbPerPage = 5; 

     $listBestiaires = $this->getDoctrine() 
      ->getManager() 
      ->getRepository('TolkienBestiaireBundle:Bestiaire') 
      ->findAll(); 

     $nbPages = ceil(count($listBestiaires)/$nbPerPage); 


     return $this->render('TolkienBestiaireBundle:Bestiaire:index.html.twig', array(
      'listBestiaires' => $listBestiaires, 
      'nbPages'  => $nbPages, 
      'page'  => $page, 
     )); 

    } 

    public function bestiaireAction() 
    { 
     $listBestiaires = $this->getDoctrine() 
      ->getManager() 
      ->getRepository('TolkienBestiaireBundle:Bestiaire') 
      ->findAll(); 


     return $this->render('TolkienBestiaireBundle:Bestiaire:bestiaire.html.twig', array(
      'listBestiaires' => $listBestiaires 
     )); 

    } 

    public function viewAction(Bestiaire $bestiaire) 
    { 
     $em = $this->getDoctrine()->getManager(); 

     $listApplications = $em 
      ->getRepository('TolkienBestiaireBundle:Application') 
      ->findBy(array('bestiaire' => $bestiaire)); 



     return $this->render('TolkienBestiaireBundle:Bestiaire:view.html.twig', array(
      'bestiaire'  => $bestiaire, 
      'listApplications' => $listApplications, 
     )); 
    } 
    /** 
    * @Security("has_role('ROLE_AUTEUR') or has_role('ROLE_USER') or has_role('ROLE_ADMIN') ") 
    */ 
    public function addAction(Request $request) 
    { 
     $bestiaire = new Bestiaire(); 
     $form = $this->get('form.factory')->create(BestiaireType::class, $bestiaire); 

     if ($request->isMethod('POST') && $form->handleRequest($request)->isValid()) { 


      $em = $this->getDoctrine()->getManager(); 
      $em->persist($bestiaire); 
      $em->flush(); 

      $request->getSession()->getFlashBag()->add('notice', 'Annonce bien enregistrée.'); 

      return $this->redirectToRoute('tolkien_bestiaire_view', array('id' => $bestiaire->getId())); 
     } 
     return $this->render('TolkienBestiaireBundle:Bestiaire:add.html.twig', array(
      'form' => $form->createView(), 
     )); 
    } 



    /** 
    * @Security("has_role('ROLE_AUTEUR') or has_role('ROLE_USER') or has_role('ROLE_ADMIN') ") 
    */ 
    public function editAction($id, Request $request) 
    { 
     $em = $this->getDoctrine()->getManager(); 

     $bestiaire = $em->getRepository('TolkienBestiaireBundle:Bestiaire')->find($id); 

     if (null === $bestiaire) { 
      throw new NotFoundHttpException("L'annonce d'id ".$id." n'existe pas."); 
     } 

     $form = $this->get('form.factory')->create(BestiaireEditType::class, $bestiaire); 

     if ($request->isMethod('POST') && $form->handleRequest($request)->isValid()) { 
      $em->flush(); 

      $request->getSession()->getFlashBag()->add('notice', 'Annonce bien modifiée.'); 

      return $this->redirectToRoute('tolkien_bestiaire_view', array('id' => $bestiaire->getId())); 
     } 

     return $this->render('TolkienBestiaireBundle:Bestiaire:edit.html.twig', array(
      'bestiaire' => $bestiaire, 
      'form' => $form->createView(), 
     )); 
    } 

    /** 
    * @Security("has_role('ROLE_ADMIN')") 
    */ 
    public function deleteAction(Request $request, Bestiaire $bestiaire) 
    { 
     $em = $this->getDoctrine()->getManager(); 

     $form = $this->get('form.factory')->create(); 

     if($request->isMethod('POST') && $form->handleRequest($request)->isValid()) 
     { 
      $em->remove($bestiaire); 
      $em->flush(); 

      $request->getSession()->getFlashBag()->add('info', "L'annonce a bien été suprimée."); 

      return $this->redirectToRoute('tolkien_bestiaire_home'); 
     } 

     return $this->render('TolkienBestiaireBundle:Bestiaire:delete.html.twig', array(
      'bestiaire' => $bestiaire, 
      'form' => $form->createView() 
     )); 
    } 

    public function menuAction($limit) 
    { 
     $em = $this->getDoctrine()->getManager(); 

     $listBestiaires = $em->getRepository('TolkienBestiaireBundle:Bestiaire')->findBy(
      array(), 
      array('date' => 'desc'), 
      $limit, 
      0 
     ); 

     return $this->render('TolkienBestiaireBundle:Bestiaire:menu.html.twig', array(
      'listBestiaires' => $listBestiaires 
     )); 
    } 

    public function translationAction($name) 
    { 
     return $this->render('TolkienBestiaireBundle:Bestiaire:translation.html.twig', array(
      'name' => $name 
     )); 
    } 

    /** 
    * @ParamConverter("json") 
    */ 
    public function ParamConverterAction($json) 
    { 
     return new Response(print_r($json, true)); 
    } 

    public function searchAction($name, Request $request) 
    { 
     $em = $this->getDoctrine()->getManager(); 
     $query = $this->getRequest()->get('query'); 

     if (!$query) 
     { 
      if(!$request->isXmlHttpRequest()){ 
       return $this->redirect($this->generateUrl('tolkien_bestiaire')); 
      } else { 
       return new Response('No results.'); 
      } 
     } 

     $bestiaire = $em->getRepository('TolkienBestiaireBundle:Bestiaire')->find($name); 

     if($request->isXmlHttpRequest()) { 
      if('*' == $query || !$bestiaire || $query == '') { 
       return new Response('No results.'); 
      } 
      return $this->render('TolkienBestiaireBundle:Bestiaire:index.html.twig', array('bestiaire' => $bestiaire)); 
     } 

     return $this->render('TolkienBestiaireBundle:Bestiaire:search.html.twig', array(
      'bestiaire' => $bestiaire 
     )); 

    } 

    public function testSearch() 
    { 
     $client = static::createClient(); 

     $crawler = $client->request('GET', '/bestiaire/search'); 
     $this->assertEquals('Tolkien\BestiaireBundle\Controller\BestiaireController::searchAction', $client->getRequest()->attributes->get('_controller')); 

     $crawler = $client->request('GET', '/bestiaire/search?query=sens*', array(), array(), array(
      'X-Requested-With' => 'XMLHttpRequest', 
     )); 
     $this->assertTrue($crawler->filter('tr')->count()== 2); 
    } 

    public function updateDataAction(Request $request) 
    { 
     $data = $request->get('input'); 

     $em = $this->getDoctrine()->getManager(); 

     $query = $em->createQuery('' 
      . 'SELECT c.id, c.name ' 
      . 'FROM TolkienBestiaireBundle:Bestiaire c ' 
      . 'WHERE c.name LIKE :data ' 
      . 'ORDER BY c.name ASC' 
     ) 
      ->setParameter('data', '%' . $data . '%'); 
     $results = $query->getResult(); 

     $bestiaireList = '<ul id="matchList">'; 
     foreach ($results as $result) { 
      $matchStringBold = preg_replace('/('.$data.')/i', '<strong>$1</strong>', $result['name']); // Replace text field input by bold one 
      $bestiaireList .= '<li id="'.$result['name'].'">'.$matchStringBold.'</li>'; // Create the matching list - we put maching name in the ID too 
     } 
     $bestiaireList .= '</ul>'; 

     $response = new JsonResponse(); 
     $response->setData(array('countryList' => $bestiaireList)); 
     return $response; 
    } 

} 

SRC /托尔金/ BestiaireBundle /资源/配置/ routing.yml中:

tolkien_bestiaire_home: 
    path:  /{page} 
    defaults: 
     _controller: TolkienBestiaireBundle:Bestiaire:index 
     page:  1 
    requirements: 
     page: \d* 

tolkien_bestiaire_bestiaire: 
    path: /bestiaire 
    defaults: 
     _controller: TolkienBestiaireBundle:Bestiaire:bestiaire 

tolkien_bestiaire_view: 
    path:  /bestiaire/{id} 
    defaults: 
     _controller: TolkienBestiaireBundle:Bestiaire:view 
    requirements: 
     id: \d+ 

tolkien_bestiaire_add: 
    path:  /add 
    defaults: 
     _controller: TolkienBestiaireBundle:Bestiaire:add 

tolkien_bestiaire_edit: 
    path:  /edit/{id} 
    defaults: 
     _controller: TolkienBestiaireBundle:Bestiaire:edit 
    requirements: 
     id: \d+ 

tolkien_bestiaire_delete: 
    path:  /delete/{id} 
    defaults: 
     _controller: TolkienBestiaireBundle:Bestiaire:delete 
    requirements: 
     id: \d+ 

tolkien_bestiaire_paramconverter: 
    path: /test/{json} 
    defaults: 
     _controller: "TolkienBestiaireBundle:Bestiaire:ParamConverter" 


tolkien_bestiaire_search: 
    path:/
    defaults: 
     _controller: "TolkienBestiaireBundle:Bestiaire:search" 


tuto_autocomplete: 
    path:  /autocomplete 
    defaults: { _controller: Sim100TutoBundle:Autocomplete:index } 

ajax_autocomplete_countries: 
    path: /ajax/autocomplete/update/data 
    defaults: { _controller: Sim100TutoBundle:AjaxAutocomplete:updateData } 

虚拟主机:

<VirtualHost *:80> 
    ServerName localhost 
    DocumentRoot c:/wamp64/www 
    <Directory "c:/wamp64/www/"> 
     Options +Indexes +FollowSymLinks +MultiViews 
     AllowOverride All 
     Require local 
    </Directory> 
</VirtualHost> 

<VirtualHost *:80> 
    ServerName virtual-host-tolkien-bestiaire 
    DocumentRoot c:/wamp64/www/tolkien-bestiaire 
    <Directory "c:/wamp64/www/tolkien-bestiaire/"> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride All 
     Require local 
    </Directory> 
</VirtualHost> 
0

右键,然后如果它的工作原理,你的路由是好的...

您可以编辑和删除您从/web
复制的代码文件这不,当我说我闯民宅该文件的虚拟主机配置

我指的apache2的配置文件为您的网站 (这里为例:http://symfony.com/doc/current/setup/web_server_configuration.html

此致似乎不完全

如果你想查看你的工作结果而不必清除缓存,那么你必须通过app_dev.php文件(http://tolkienbestiaire.esy.es/app_dev.php

虽然,该链接只有在对虚拟主机进行更正后才能使用。

0

我编辑了我的答案。

虚拟主机:

<VirtualHost *:80> 
    ServerName localhost 
    DocumentRoot c:/wamp64/www 
    <Directory "c:/wamp64/www/"> 
     Options +Indexes +FollowSymLinks +MultiViews 
     AllowOverride All 
     Require local 
    </Directory> 
</VirtualHost> 

<VirtualHost *:80> 
    ServerName virtual-host-tolkien-bestiaire 
    DocumentRoot c:/wamp64/www/tolkien-bestiaire 
    <Directory "c:/wamp64/www/tolkien-bestiaire/"> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride All 
     Require local 
    </Directory> 
</VirtualHost> 
0

我跳了,你会来看看我给你的Symfonny文档的链接,找到你做错了什么......

你的虚拟主机点c:/wamp64/www/tolkien-bestiaire/而不是c:/wamp64/www/tolkien-bestiaire/web/

此外,如果c:/wamp64/www/tolkien-bestiaire是symfony项目的目录,则不需要同一文件中的第一个虚拟主机。
它首先被推荐为每个文件只有一个虚拟主机。

Symfony doc(http://symfony.com/doc/current/setup/web_server_configuration.html)的第二个例子是Symfony的一个很好的虚拟主机文件。

我会建议你运行端子和enamble重写模块a2enmod rewrite

这样做应该做它去你的网站可能与此链接http://tolkienbestiaire.esy.es,而不是你给前面的链接。

希望它帮助你解决了虚拟主题问题。