Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [SF2][Symfony][Symfony2]Annotations z routingu nie działa
Crash89
post
Post #1





Grupa: Zarejestrowani
Postów: 191
Pomógł: 7
Dołączył: 3.04.2013

Ostrzeżenie: (0%)
-----


Stworzyłem nowy projekt na symfony 4 i chciałem skorzystać z adnotacji dla routingu.
Podążając za dokumentacją, niestety po instalacji tychże i próbie uruchomienia jakiegoś routingu z tych adnotacji pojawia się błąd:

Exception thrown when handling an exception (Symfony\Component\Config\Exception\FileLoaderLoadException: Warning: strtoupper() expects parameter 1 to be string, array given in D:\xampp\htdocs\projekt\config/routes\../../src/Controller/ (which is being imported from "D:\xampp\htdocs\projekt\config/routes/annotations.yaml"). Make sure annotations are installed and enabled.)

Czy ktoś miał już taki problem?

Ten post edytował Crash89 26.05.2018, 09:24:11
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Crash89
post
Post #2





Grupa: Zarejestrowani
Postów: 191
Pomógł: 7
Dołączył: 3.04.2013

Ostrzeżenie: (0%)
-----


Cytat(ohm @ 27.05.2018, 13:00:24 ) *
Nie za daleko wyjechałeś z katalogiem z tymi annotacjami?
https://github.com/symfony/demo/blob/master...nnotations.yaml


Chyba nie, ta zmiana nic nie zmienia.
Tak mi framework stworzył ten plik.


Cytat(Pyton_000 @ 27.05.2018, 13:00:30 ) *
pokaż klasę po zmianach


  1.  
  2. <?php
  3.  
  4. namespace App\Controller;
  5.  
  6. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  7. //use Symfony\Component\Routing\Annotation\Route;
  8. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  11.  
  12. /**
  13.  * Class LuckyController
  14.  * @package App\Controller
  15.  */
  16. class LuckyController extends Controller
  17. {
  18. /**
  19.   * @Route("/")
  20.   */
  21. public function number()
  22. {
  23.  
  24. $number = 10;
  25. return new Response(
  26. '<html><body>Lucky number: '.$number.'</body></html>'
  27. );
  28. }
  29.  
  30. /**
  31.  * @Route("/test", methods={"POST","GET"})
  32.  *
  33.  */
  34. public function test()
  35. {
  36.  
  37. return new Response(
  38. '<html><body>test</body></html>'
  39. );
  40.  
  41. }
  42. }


cały czas odpalam metode number.

Ten post edytował Crash89 27.05.2018, 12:11:59
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 8.10.2025 - 16:10