Bonjour,
J'ai plusieurs erreurs concernant la mise en ligne de mon application notamment celle-ci :

An exception occurred while executing 'SELECT t0.id AS id_1, t0.name AS name_2 FROM listing t0':
Notice: Undefined variable: argsCount

Malgré plusieurs forums et documentations je n'arrive toujours pas à afficher ma page.... :/
Si quelqu'un aurait une solution ça serait génial :)

6 réponses


Guizmo
Auteur
Réponse acceptée

Faudrait-il au passage créer un fichier .htaccess ?

Hello,

Il nous faut plus que ça pour voir que qui cloche.

  • Controller
  • Repository
  • entity
Guizmo
Auteur

Bonjour, d'accord bidule alors je met le code de mes fichiers,
Voici le fichier Listing.php

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**

  • @ORM\Entity(repositoryClass="App\Repository\ListingRepository")
    */
    class Listing
    {
    /**

    • @ORM\Id()
    • @ORM\GeneratedValue()
    • @ORM\Column(type="integer")
      */
      private $id;

    /**

    • @ORM\Column(type="string", length=255, unique=true)
      */
      private $name;

    /**

    • @ORM\OneToMany(targetEntity="App\Entity\Task", mappedBy="listing", cascade={"remove"})
      */
      private $tasks;

    public function getId()
    {
    return $this->id;
    }

    public function getName(): ?string
    {
    return $this->name;
    }

    public function setName(string $name): self
    {
    $this->name = $name;

    return $this;

    }

    /**

    • @return mixed
      */
      public function getTasks()
      {
      return $this->tasks;
      }
      }

Le fichier Task.php

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**

  • @ORM\Entity(repositoryClass="App\Repository\TaskRepository")
    */
    class Task
    {
    /**

    • @ORM\Id()
    • @ORM\GeneratedValue()
    • @ORM\Column(type="integer")
      */
      private $id;

    /**

    • @ORM\Column(type="string", length=255)
      */
      private $name;

    /**

    • @ORM\ManyToOne(targetEntity="App\Entity\Listing", inversedBy="tasks")
    • @ORM\JoinColumn()
      */
      private $listing;

    /**

    • @ORM\Column(type="text", nullable=true)
      */
      private $description;

    /**

    • @ORM\Column(type="datetime", nullable=true)
      */
      private $dueDate;

    /**

    • @ORM\Column(type="smallint", nullable=true)
    • @Assert\Range(
    • min = 5,
    • max = 300,
    • minMessage = "Vous devez configurer le rappel au moins 5 minutes avant la date d'échéance de la tâche",
    • maxMessage = "Vous devez configurer le rappel au plus 300 minutes avant la date d'échéance de la tâche",
    • )
      */
      private $reminder;

    public function getId()
    {
    return $this->id;
    }

    public function getName(): ?string
    {
    return $this->name;
    }

    public function setName(string $name): self
    {
    $this->name = $name;

    return $this;

    }

    public function getDescription(): ?string
    {
    return $this->description;
    }

    public function setDescription(?string $description): self
    {
    $this->description = $description;

    return $this;

    }

    /**

    • @return mixed
      */
      public function getListing()
      {
      return $this->listing;
      }

    /**

    • @param mixed $listing
      */
      public function setListing(Listing $listing): void
      {
      $this->listing = $listing;
      }

    /**

    • @return mixed
      */
      public function getDueDate()
      {
      return $this->dueDate;
      }

    /**

    • @param mixed $dueDate
      */
      public function setDueDate($dueDate): void
      {
      $this->dueDate = $dueDate;
      }

    /**

    • @return mixed
      */
      public function getReminder()
      {
      return $this->reminder;
      }

    /**

    • @param mixed $reminder
      */
      public function setReminder($reminder): void
      {
      $this->reminder = $reminder;
      }

}

Guizmo
Auteur

Fichier ListingRepository.php

<?php

namespace App\Repository;

use App\Entity\Listing;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**

  • @method Listing|null find($id, $lockMode = null, $lockVersion = null)
  • @method Listing|null findOneBy(array $criteria, array $orderBy = null)
  • @method Listing[] findAll()
  • @method Listing[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    */
    class ListingRepository extends ServiceEntityRepository
    {
    public function construct(ManagerRegistry $registry)
    {
    parent::
    construct($registry, Listing::class);
    }

    // /*
    //
    @return Listing[] Returns an array of Listing objects
    // /
    /

    public function findByExampleField($value)
    {
    return $this->createQueryBuilder('l')
    ->andWhere('l.exampleField = :val')
    ->setParameter('val', $value)
    ->orderBy('l.id', 'ASC')
    ->setMaxResults(10)
    ->getQuery()
    ->getResult()
    ;
    }
    */

    /
    public function findOneBySomeField($value): ?Listing
    {
    return $this->createQueryBuilder('l')
    ->andWhere('l.exampleField = :val')
    ->setParameter('val', $value)
    ->getQuery()
    ->getOneOrNullResult()
    ;
    }
    /
    }

Fichier TaskRepository.php

<?php

namespace App\Repository;

use App\Entity\Task;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**

  • @method Task|null find($id, $lockMode = null, $lockVersion = null)
  • @method Task|null findOneBy(array $criteria, array $orderBy = null)
  • @method Task[] findAll()
  • @method Task[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    */
    class TaskRepository extends ServiceEntityRepository
    {
    public function construct(ManagerRegistry $registry)
    {
    parent::
    construct($registry, Task::class);
    }

    // /*
    //
    @return Task[] Returns an array of Task objects
    // /
    /

    public function findByExampleField($value)
    {
    return $this->createQueryBuilder('t')
    ->andWhere('t.exampleField = :val')
    ->setParameter('val', $value)
    ->orderBy('t.id', 'ASC')
    ->setMaxResults(10)
    ->getQuery()
    ->getResult()
    ;
    }
    */

    /
    public function findOneBySomeField($value): ?Task
    {
    return $this->createQueryBuilder('t')
    ->andWhere('t.exampleField = :val')
    ->setParameter('val', $value)
    ->getQuery()
    ->getOneOrNullResult()
    ;
    }
    /
    }

Guizmo
Auteur

ListingController.php :

<?php

namespace App\Controller;

use App\Entity\Listing;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**

  • @Route("/", name="listing_")
    */

class ListingController extends AbstractController
{
/**

  • @Route("/{listingId}", name="show", requirements={"listingId"="\d+"})
    */
    public function show(EntityManagerInterface $entityManager, $listingId = null)
    {
    $listings = $entityManager->getRepository(Listing::class)->findAll();

    if (!empty($listingId)){
        $currentListing = $entityManager->getRepository(Listing::class)->find($listingId);
    }
    
    if (empty($currentListing)){
        $currentListing = current($listings);
    }
    
    return $this->render("listing.html.twig", ['listings' => $listings, 'currentListing' => $currentListing]);

    }

    /**

  • @Route("/new", methods="POST", name="create")
    */
    public function create(EntityManagerInterface $entityManager, Request $request)
    {
    $name = $request->get('name');

    if(empty($name)) {
        $this->addFlash(
            "warning",
            "Un nom de liste est obligatoire !"
        );
        return $this->redirectToRoute('listing_show');
    }
    
    $listing = new Listing();
    $listing->setName($name);
    
    try {
        $entityManager->persist($listing);
        $entityManager->flush();
    
        $this->addFlash(
            "success",
            "La liste « $name » a été crée avec succès"
        );
    } catch (UniqueConstraintViolationException $e) {
        $this->addFlash(
            "warning",
            "La liste $name existe déjà."
        );
    }
    
    return $this->redirectToRoute('listing_show');

    }

    /**

  • @Route("/{listingId}/delete", name="delete", requirements={"listingId"="\d+"})
    */
    public function delete(EntityManagerInterface $entityManager, $listingId)
    {
    $listing = $entityManager->getRepository(Listing::class)->find($listingId);

    if (empty($listing)) {
        $this->addFlash(
            "warning",
            "Impossible de supprimer de la liste"
        );
    } else {
        $entityManager->remove($listing);
        $entityManager->flush();
    
        $name = $listing->getName();
    
        $this->addFlash(
            "success",
            "La liste $name à été supprimé avec succès"
        );
    }
    
    return $this->redirectToRoute('listing_show');

    }
    }

TaskController.php :

<?php

namespace App\Controller;

use App\Entity\Task;
use App\Entity\Listing;
use App\Form\TaskType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

/**

  • @Route("{listingId}/task", name="task_", requirements={"listingId"="\d+"})
    */
    class TaskController extends AbstractController
    {
    /**

    • @Route("/new", name="create")
      */
      public function create(EntityManagerInterface $entityManager, Request $request, $listingId)
      {
      $listing = $entityManager->getRepository(Listing::class)->find($listingId);

      $task = new Task();
      $task->setListing($listing);

      $form = $this->createForm(TaskType::class, $task);

      $form->handleRequest($request);

      if ($form->isSubmitted() && $form->isValid()) {
      $entityManager->persist($task);
      $entityManager->flush();

      return $this->redirectToRoute('listing_show', ['listingId' => $listingId]);

      }

      return $this->render('task.html.twig', ['form' => $form->createView()]);
      }

    /**

    • @Route("/{taskId}/edit", name="edit", requirements={"taskId"="\d+"})
      */
      public function edit(EntityManagerInterface $entityManager, Request $request, $listingId, $taskId)
      {
      $task = $entityManager->getRepository(Task::class)->find($taskId);

      if (empty($task)) {
      $this->addFlash(
      'warning',
      'Impossible de modifier la tâche'
      );

      return $this->redirectToRoute('listing_show', ['listingId' => $listingId]);

      }

      $name = $task->getName();

      $form = $this->createForm(TaskType::class, $task);

      $form->handleRequest($request);

      if ($form->isSubmitted() && $form->isValid()) {
      $entityManager->flush();

      $this->addFlash(
          'success', 
          "La tâche $name a été modifiée avec succès"
      );
      
      return $this->redirectToRoute('listing_show', ['listingId' => $listingId]);

      }

      return $this->render('task.html.twig', ['form' => $form->createView()]);
      }

    /**

    • @Route("/{taskId}/delete", name="delete", requirements={"taskId"="\d+"})
      */
      public function delete(EntityManagerInterface $entityManager, Request $request, $listingId, $taskId)
      {
      $task = $entityManager->getRepository(Task::class)->find($taskId);

      if (empty($task)) {
      $this->addFlash(
      'warning',
      'Impossible de supprimer la tâche'
      );

      return $this->redirectToRoute('listing_show', ['listingId' => $listingId]);

      } else {

      $name = $task->getName();
      
      $entityManager->remove($task);
      $entityManager->flush();
      
          $this->addFlash(
              'success', 
              "La tâche $name a été supprimer"
          );
      }
      
      return $this->redirectToRoute('listing_show', ['listingId' => $listingId]);

    }
    }

Guizmo
Auteur

J'ai réussi à faire marcher mon application !!
En gros j'ai tout supprimé mes fichiers symfony de Filezilla.
1 - Dans mon dossier application_web j'ai crée en ligne de commande CMD un fichier .htaccess en faisant : composer require symfony/apache-pack
Celui-ci c'est crée dans le dossier public/
2 - Vider le cache en faisant :
php bin/console cache:clear
3 - Vider le cache de production :
php bin/console cache:clear --env=prod
4 - Remettre tous les fichiers dans le serveur filleZilla avec les infos de la base de donnée de l'hébergeur et ça marche !