From c4ade2cd1e99cb16627ba5353ce337a7dd05bf72 Mon Sep 17 00:00:00 2001 From: cjbaezilla Date: Tue, 10 Mar 2026 20:25:12 -0300 Subject: [PATCH] class defined as "Ping" but endpoints trying to fetch "Pings" --- docs/guides/api/first-endpoint.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/guides/api/first-endpoint.html b/docs/guides/api/first-endpoint.html index a0aa2844..f9099c09 100644 --- a/docs/guides/api/first-endpoint.html +++ b/docs/guides/api/first-endpoint.html @@ -321,7 +321,7 @@

Enable Improved Auto
public bool $autoRoute = true;
 
-

That’s all you need for CodeIgniter to automatically map your controller classes and to URIs like GET /api/pings or POST /api/pings.

+

That’s all you need for CodeIgniter to automatically map your controller classes and to URIs like GET /api/ping or POST /api/ping.

Create a Ping Controller

@@ -353,7 +353,7 @@

Create a Ping Control

Here we:

  • Use the ResponseTrait, which already includes REST helpers such as respond() and proper status codes.

  • -
  • Define a getIndex() method. The get prefix means it responds to GET requests, and the Index name means it matches the base URI (/api/pings).

  • +
  • Define a getIndex() method. The get prefix means it responds to GET requests, and the Index name means it matches the base URI (/api/ping).

@@ -364,8 +364,8 @@

Test the route

Now visit:

    -
  • Browser: http://localhost:8080/api/pings

  • -
  • cURL: curl http://localhost:8080/api/pings

  • +
  • Browser: http://localhost:8080/api/ping

  • +
  • cURL: curl http://localhost:8080/api/ping

Expected response:

{
@@ -377,9 +377,9 @@ 

Test the route

Understand how it works

-

When you request /api/pings:

+

When you request /api/ping:

    -
  1. The Improved Auto Router finds the App\Controllers\Api\Pings class.

  2. +
  3. The Improved Auto Router finds the App\Controllers\Api\Ping class.

  4. It detects the HTTP verb (GET).

  5. It calls the corresponding method name: getIndex().

  6. ResponseTrait provides helper methods to produce consistent output.

  7. @@ -392,9 +392,9 @@

    Understand how it wor -

    GET /api/pings -POST /api/pings -DELETE /api/pings

    +

    GET /api/ping +POST /api/ping +DELETE /api/ping

    getIndex() postIndex() deleteIndex()