IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Symfony PHP Discussion :

"Unable to find template" seulement en production


Sujet :

Symfony PHP

  1. #1
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2019
    Messages : 13
    Points : 13
    Points
    13
    Par défaut "Unable to find template" seulement en production
    Bonsoir tout le monde,

    Je viens de deployer mon application, et j'ai un soucis avec une de mes vues que je n'ai pas en local.

    Unable to find template "offer/_offer.html.twig " (looked into: /home/u726646235/public_html/studyjob/templates, /home/u726646235/public_html/studyjob/vendor/symfony/twig-bridge/Resources/views/Form) in offer/index.html.twig at line 12.
    Au niveau de mon arborescence j'ai :
    offer 
      |_ _offer.html.twig
      |_ index.html.twig
    Voici l'action de mon controller par rapport à ma vue :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
     /**
         * @Route("/offers/{page<\d+>?1}", name="offers_index")
         */
        public function index(OfferRepository $repo, $page)
        {
            $limit = 9;
     
            $start = $page * $limit - $limit;
     
            $total = count($repo->findAll());
     
            $pages = ceil($total / $limit);
     
            return $this->render('offer/index.html.twig', [
                'offers' => $repo->findBy([], [], $limit, $start),
                'pages' => $pages,
                'page' => $page
            ]);
        }
    Merci d'avance.

    J'ai oublié de préciser que ma vue _offer.html.twig est include dans index.html.twig.

  2. #2
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 496
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 496
    Points : 12 596
    Points
    12 596
    Par défaut
    Donc ce qui nous intéresse est de voir le fichier index.html.twig pour voir ce qui peut provoquer l'erreur suivante.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    Unable to find template "offer/_offer.html.twig "

  3. #3
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2019
    Messages
    13
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 26
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mars 2019
    Messages : 13
    Points : 13
    Points
    13
    Par défaut
    Et voilà :

    Code twig : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    {% set url = path('offers_show', {'slug': offer.slug}) %}
     
    <div class="col-12 col-md-6 col-lg-4">
    	<div class="card bg-light mb-3">
    		<div class="card-header text-center">
    			Offre postée par <a href="{{path('user_show', {"slug" : offer.author.slug})}}">{{ offer.author.fullName }}</a>
    		</div>
    		<div class="card-body">
    			<h4 class="card-title">
    				<a href="{{url}}">
    					{{ offer.title }}
    				</a>
    			</h4>
    			<p class="card-text" style=" overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;">
    				{{ offer.description | raw }}
    			</p>
    			<div class="row">
    				{% if app.user and app.user == offer.author and is_granted('ROLE_EMPLOYER') %}
    					<div class="col-12 mb-4">
    						<div class="row text-center">
    							<div class="col-12 mb-4">
    								<a href="{{url}}" class="btn btn-primary">Voir l'offre</a>	
    							</div>
    							<div class="col-6">
    								<a href="{{ path('offers_edit', {'slug': offer.slug}) }}" class="btn btn-secondary">Modifier l'offre</a>
    							</div>					
    							<div class="col-6">
    								<a href="{{ path('offers_delete', {'slug': offer.slug}) }}" class="btn btn-danger" onclick="return confirm(`Êtes vous sur de vouloir supprimer l'offre : {{offer.title}} ?`)">Supprimer l'offre</a>	
    							</div>
    						</div>
    					</div>
    				{% else %}
    					<div class="col">
    						<a href="{{url}}" class="btn btn-primary">En savoir plus !</a>
    					</div>
    				{% endif %}
    			</div>
    		</div>
    	</div>
    </div>

  4. #4
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 496
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 496
    Points : 12 596
    Points
    12 596
    Par défaut
    Ce n'est pas le fichier index

Discussions similaires

  1. Unable to find template
    Par MInfo25 dans le forum Débuter
    Réponses: 3
    Dernier message: 27/04/2016, 13h07
  2. [2.x] [Symfony2] Unable to find template malgré cache:clear
    Par zozoman dans le forum Symfony
    Réponses: 2
    Dernier message: 09/04/2014, 10h37
  3. [Symfony2] Unable to find template malgré cache:clear
    Par zozoman dans le forum Bibliothèques et frameworks
    Réponses: 0
    Dernier message: 21/03/2014, 17h44
  4. [2.x] Twig, unable to find template
    Par khalid95800 dans le forum Symfony
    Réponses: 2
    Dernier message: 04/09/2013, 14h21
  5. [2.x] "Unable to find template" en prod
    Par laupas dans le forum Symfony
    Réponses: 1
    Dernier message: 22/05/2012, 21h22

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo