Mam taki problem, że zainstalowałem symfony, coś tam z GPT napisaliśmy ale nie renderuje mi strony wynikowej
kod
<?php
// src/Controller/LuckyController.php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class LuckyController
{
public function number(): Response
{
$number = random_int(0, 100);
// Creating a Response object with the generated random number
$html = '<html><body>';
$html .= '<h1>Your lucky number is: ' . $number . '</h1>';
$html .= '</body></html>';
// Return the Response object
return new Response($html);
}
}
wyświetla mi jako tekst
// src/Controller/LuckyController.php namespace App\Controller; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; class LuckyController { public function number(): Response { $number = random_int(0, 100); // Creating a Response object with the generated random number $html = ''; $html .= '
Your lucky number is: ' . $number . '
'; $html .= ''; // Return the Response object return new Response($html); } }
php 8.24
Dodałem <?php
i wypluwa pusty dokument
Uruchomiłem serwer symfony w katalogu zmieniłem nazwę projektu na index.php
nie działą
Uruchomiłem xampp z oryginalną nazwą projektu i nic nie pokazuje
GPT
Apologies for the confusion earlier. In the code snippet you provided, the
#[Route]
annotation is missing. To define a route using annotations, you need to add the#[Route]
annotation above the controller method you want to associate with a specific URL.
Sam to napisał godzinę wcześniej.
```
. Jesteś na forum już długo, powinieneś to wiedzieć. https://4programmers.net/Forum/Spolecznosc/355922-dlaczego_nie_nalezy_zamieszczac_kodu_w_postaci_obrazkow