Instead of PHPDoc annotations, you can now use structured metadata with PHP’s native syntax.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // PHP 7 class PostsController { /** * @Route("/api/posts/{id}", methods={"GET"}) */ public function get( $id ) { /* ... */ } } // PHP 8 class PostsController { #[Route( "/api/posts/{id}" , methods: [ "GET" ])] public function get( $id ) { /* ... */ } } |
That’s it!. Please share your thoughts or suggestions in the comments below.