Symfony Exception

RuntimeError

HTTP 500 Internal Server Error

Impossible to access an attribute ("titre") on a null variable.

Exception

Twig\Error\ RuntimeError

  1.                 <div class="row mt-2 border">
  2.                     <div class="col-lg-12 p-3">
  3.                         <div class="row">
  4.                             <div class="col-sm-8">
  5.                                 <h2 class="text-danger">
  6.                                     {{ item.titre }}
  7.                                 </h2>
  8.                                 <p class="fst-italic">
  9.                                     {% if item.codePostal|slice(0,1) == "9" %}
  10.                                         {{ item.codePostal|slice(0,3) }}
  11.                                     {% else %}
in vendor/twig/twig/src/Template.php->block_content (line 182)
  1.             throw new \LogicException('A block must be a method on a \Twig\Template instance.');
  2.         }
  3.         if (null !== $template) {
  4.             try {
  5.                 $template->$block($context$blocks);
  6.             } catch (Error $e) {
  7.                 if (!$e->getSourceContext()) {
  8.                     $e->setSourceContext($template->getSourceContext());
  9.                 }
in vendor/twig/twig/src/Template.php->doDisplay (line 405)
  1.     }
  2.     protected function displayWithErrorHandling(array $context, array $blocks = [])
  3.     {
  4.         try {
  5.             $this->doDisplay($context$blocks);
  6.         } catch (Error $e) {
  7.             if (!$e->getSourceContext()) {
  8.                 $e->setSourceContext($this->getSourceContext());
  9.             }
in vendor/twig/twig/src/Template.php->displayWithErrorHandling (line 378)
  1.         return $this->blocks;
  2.     }
  3.     public function display(array $context, array $blocks = [])
  4.     {
  5.         $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks$blocks));
  6.     }
  7.     public function render(array $context)
  8.     {
  9.         $level ob_get_level();
in vendor/twig/twig/src/Template.php->doDisplay (line 405)
  1.     }
  2.     protected function displayWithErrorHandling(array $context, array $blocks = [])
  3.     {
  4.         try {
  5.             $this->doDisplay($context$blocks);
  6.         } catch (Error $e) {
  7.             if (!$e->getSourceContext()) {
  8.                 $e->setSourceContext($this->getSourceContext());
  9.             }
in vendor/twig/twig/src/Template.php->displayWithErrorHandling (line 378)
  1.         return $this->blocks;
  2.     }
  3.     public function display(array $context, array $blocks = [])
  4.     {
  5.         $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks$blocks));
  6.     }
  7.     public function render(array $context)
  8.     {
  9.         $level ob_get_level();
in vendor/twig/twig/src/Template.php->block_body (line 182)
  1.             throw new \LogicException('A block must be a method on a \Twig\Template instance.');
  2.         }
  3.         if (null !== $template) {
  4.             try {
  5.                 $template->$block($context$blocks);
  6.             } catch (Error $e) {
  7.                 if (!$e->getSourceContext()) {
  8.                     $e->setSourceContext($template->getSourceContext());
  9.                 }
in vendor/twig/twig/src/Template.php->doDisplay (line 405)
  1.     }
  2.     protected function displayWithErrorHandling(array $context, array $blocks = [])
  3.     {
  4.         try {
  5.             $this->doDisplay($context$blocks);
  6.         } catch (Error $e) {
  7.             if (!$e->getSourceContext()) {
  8.                 $e->setSourceContext($this->getSourceContext());
  9.             }
in vendor/twig/twig/src/Template.php->displayWithErrorHandling (line 378)
  1.         return $this->blocks;
  2.     }
  3.     public function display(array $context, array $blocks = [])
  4.     {
  5.         $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks$blocks));
  6.     }
  7.     public function render(array $context)
  8.     {
  9.         $level ob_get_level();
in vendor/twig/twig/src/Template.php->doDisplay (line 405)
  1.     }
  2.     protected function displayWithErrorHandling(array $context, array $blocks = [])
  3.     {
  4.         try {
  5.             $this->doDisplay($context$blocks);
  6.         } catch (Error $e) {
  7.             if (!$e->getSourceContext()) {
  8.                 $e->setSourceContext($this->getSourceContext());
  9.             }
in vendor/twig/twig/src/Template.php->displayWithErrorHandling (line 378)
  1.         return $this->blocks;
  2.     }
  3.     public function display(array $context, array $blocks = [])
  4.     {
  5.         $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks$blocks));
  6.     }
  7.     public function render(array $context)
  8.     {
  9.         $level ob_get_level();
in vendor/twig/twig/src/Template.php->display (line 390)
  1.             ob_start();
  2.         } else {
  3.             ob_start(function () { return ''; });
  4.         }
  5.         try {
  6.             $this->display($context);
  7.         } catch (\Throwable $e) {
  8.             while (ob_get_level() > $level) {
  9.                 ob_end_clean();
  10.             }
  1.      */
  2.     public function render(array $context = []): string
  3.     {
  4.         // using func_get_args() allows to not expose the blocks argument
  5.         // as it should only be used by internal code
  6.         return $this->template->render($context, \func_get_args()[1] ?? []);
  7.     }
  8.     /**
  9.      * Displays the template.
  10.      *
in vendor/twig/twig/src/Environment.php->render (line 318)
  1.      * @throws SyntaxError  When an error occurred during compilation
  2.      * @throws RuntimeError When an error occurred during rendering
  3.      */
  4.     public function render($name, array $context = [])
  5.     {
  6.         return $this->load($name)->render($context);
  7.     }
  8.     /**
  9.      * Displays a template.
  10.      *
  1.     protected function render(string $view, array $parameters = [], Response $response null): Response
  2.     {
  3.         if ($this->container->has('templating')) {
  4.             $content $this->container->get('templating')->render($view$parameters);
  5.         } elseif ($this->container->has('twig')) {
  6.             $content $this->container->get('twig')->render($view$parameters);
  7.         } else {
  8.             throw new \LogicException('You can not use the "render" method if the Templating Component or the Twig Bundle are not available. Try running "composer require symfony/twig-bundle".');
  9.         }
  10.         if (null === $response) {
Controller->render() in src/Controller/AnnuaireJournauxController.php (line 68)
  1.     }
  2.     public function detail($journal)
  3.     {
  4.         $journal_data       $this->getDoctrine()->getManager()->getRepository("VenteEnchere\Entity\Journaux")->find($journal);
  5.         
  6.         return $this->render('annuaire_journaux/detail.html.twig', ['item' => $journal_data ]);
  7.     }
  8. }
  1.         $this->dispatcher->dispatch(KernelEvents::CONTROLLER_ARGUMENTS$event);
  2.         $controller $event->getController();
  3.         $arguments $event->getArguments();
  4.         // call controller
  5.         $response $controller(...$arguments);
  6.         // view
  7.         if (!$response instanceof Response) {
  8.             $event = new GetResponseForControllerResultEvent($this$request$type$response);
  9.             $this->dispatcher->dispatch(KernelEvents::VIEW$event);
  1.     public function handle(Request $request$type HttpKernelInterface::MASTER_REQUEST$catch true)
  2.     {
  3.         $request->headers->set('X-Php-Ob-Level'ob_get_level());
  4.         try {
  5.             return $this->handleRaw($request$type);
  6.         } catch (\Exception $e) {
  7.             if ($e instanceof RequestExceptionInterface) {
  8.                 $e = new BadRequestHttpException($e->getMessage(), $e);
  9.             }
  10.             if (false === $catch) {
  1.         $this->boot();
  2.         ++$this->requestStackSize;
  3.         $this->resetServices true;
  4.         try {
  5.             return $this->getHttpKernel()->handle($request$type$catch);
  6.         } finally {
  7.             --$this->requestStackSize;
  8.         }
  9.     }
Kernel->handle() in public/index.php (line 25)
  1.     Request::setTrustedHosts([$trustedHosts]);
  2. }
  3. $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
  4. $request Request::createFromGlobals();
  5. $response $kernel->handle($request);
  6. $response->send();
  7. $kernel->terminate($request$response);

Logs

No log messages

Stack Trace

RuntimeError

Twig\Error\RuntimeError:
Impossible to access an attribute ("titre") on a null variable.

  at templates/annuaire_journaux/detail.html.twig:52
  at twig_get_attribute()
     (vendor/twig/twig/src/Environment.php(418) : eval()'d code:381)
  at __TwigTemplate_24efb783cd82d8c9745998b9c19f5dc58dd5f4a85ed785d0f36ac154355d7e09___162694056->block_content()
     (vendor/twig/twig/src/Template.php:182)
  at Twig\Template->displayBlock()
     (vendor/twig/twig/src/Environment.php(418) : eval()'d code:62)
  at __TwigTemplate_5544431df725f71645cfbf2032d128c976033f9070a0278fd52117d7becbb345->doDisplay()
     (vendor/twig/twig/src/Template.php:405)
  at Twig\Template->displayWithErrorHandling()
     (vendor/twig/twig/src/Template.php:378)
  at Twig\Template->display()
     (vendor/twig/twig/src/Environment.php(418) : eval()'d code:285)
  at __TwigTemplate_24efb783cd82d8c9745998b9c19f5dc58dd5f4a85ed785d0f36ac154355d7e09___162694056->doDisplay()
     (vendor/twig/twig/src/Template.php:405)
  at Twig\Template->displayWithErrorHandling()
     (vendor/twig/twig/src/Template.php:378)
  at Twig\Template->display()
     (vendor/twig/twig/src/Environment.php(418) : eval()'d code:86)
  at __TwigTemplate_24efb783cd82d8c9745998b9c19f5dc58dd5f4a85ed785d0f36ac154355d7e09->block_body()
     (vendor/twig/twig/src/Template.php:182)
  at Twig\Template->displayBlock()
     (vendor/twig/twig/src/Environment.php(418) : eval()'d code:257)
  at __TwigTemplate_31cea50d29f2158cb1aa78dcb8941e3894a7cb2f72b7c29cce3805d6011b4b59->doDisplay()
     (vendor/twig/twig/src/Template.php:405)
  at Twig\Template->displayWithErrorHandling()
     (vendor/twig/twig/src/Template.php:378)
  at Twig\Template->display()
     (vendor/twig/twig/src/Environment.php(418) : eval()'d code:46)
  at __TwigTemplate_24efb783cd82d8c9745998b9c19f5dc58dd5f4a85ed785d0f36ac154355d7e09->doDisplay()
     (vendor/twig/twig/src/Template.php:405)
  at Twig\Template->displayWithErrorHandling()
     (vendor/twig/twig/src/Template.php:378)
  at Twig\Template->display()
     (vendor/twig/twig/src/Template.php:390)
  at Twig\Template->render()
     (vendor/twig/twig/src/TemplateWrapper.php:45)
  at Twig\TemplateWrapper->render()
     (vendor/twig/twig/src/Environment.php:318)
  at Twig\Environment->render()
     (vendor/symfony/framework-bundle/Controller/ControllerTrait.php:229)
  at Symfony\Bundle\FrameworkBundle\Controller\Controller->render()
     (src/Controller/AnnuaireJournauxController.php:68)
  at VenteEnchere\Controller\AnnuaireJournauxController->detail()
     (vendor/symfony/http-kernel/HttpKernel.php:150)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
     (vendor/symfony/http-kernel/HttpKernel.php:67)
  at Symfony\Component\HttpKernel\HttpKernel->handle()
     (vendor/symfony/http-kernel/Kernel.php:198)
  at Symfony\Component\HttpKernel\Kernel->handle()
     (public/index.php:25)