Hello!

BrainTech - software solutions, web design and applications.

Contact

Module 1 – Introduction to API and HTTP Exercise

Exercise: first API call

Exercise: first API call

Hands-on exercise: Exercise: first API call. Build a small PHP 8 REST API and verify the HTTP layer before adding authentication and deployment. U REST API Masterclass kursu primenjujete PHP 8, JSON odgovore, jasne status kodove i produkcijsku strukturu projekta pre nego što API pustite klijentima ili mobilnim aplikacijama.

Task

  1. Create api-lab/ with public/index.php, src/Router.php, and config/.env sample.
  2. Run PHP built-in server: php -S localhost:8080 -t api-lab/public.
  3. Implement minimal router and one GET endpoint returning JSON with status 200.
  4. Add POST endpoint with input validation and 201 Created response.
  5. Test both endpoints with curl and save requests in Postman collection api-lab.json.
  6. Simulate error (invalid JSON) and verify API returns 400 with clear message.
  7. Add log file storage/requests.log with method, path, status, and timestamp.
  8. Optional: connect endpoint to SQLite users table for small CRUD example.

Practical example

Test API call

curl -i http://localhost:8080/api/users

Goal: Successfully implement Exercise: first API call with correct JSON responses, status codes, and documented curl examples ready for team code review. U REST API Masterclass kursu primenjujete PHP 8, JSON odgovore, jasne status kodove i produkcijsku strukturu projekta pre nego što API pustite klijentima ili mobilnim aplikacijama.

Design Wireframe
High Fidelity Design
Design development
Design development
Design development
Research development