2
0

ApiController.php 520 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Test\Michel\Controller;
  3. use Michel\Attribute\Route;
  4. class ApiController
  5. {
  6. #[Route('/api', name: 'api_index', methods: ['GET'])]
  7. public function index(): string
  8. {
  9. return json_encode([
  10. 'name' => 'John Doe',
  11. ]);
  12. }
  13. #[Route('/api', name: 'api_post', methods: ['POST'])]
  14. public function post(): string
  15. {
  16. return json_encode([
  17. 'name' => 'John Doe',
  18. 'status' => 'success'
  19. ]);
  20. }
  21. }