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
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Pokaż klasę z annotacjami.
Go to the top of the page
+Quote Post
Crash89
post
Post #3





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

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


Cytat(Pyton_000 @ 26.05.2018, 22:39:36 ) *
Pokaż klasę z annotacjami.


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


annotations.yml
  1. controllers:
  2. resource: ../../src/Controller/
  3. type: annotation


Kiedy zakomentuje plik annotations.yml, to działają routingi z pliku routes.yaml
Ale chciałbym pracować na adnotacjach.

Ten post edytował Crash89 27.05.2018, 10:28:05
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: 14.10.2025 - 12:20