---
source_hash: "181601fb"
title: "Module 8: Backend API (PHP)"
weight: 620
description: "JWT authentication is handled by SmartAuth:"
category: "Training"
type: "training"
---

# Module 8: Backend API (PHP)

> This module covers the creation of the REST API server-side: routing, controllers, mappers, and integration with Dolibarr.

## Prerequisites

- PHP and Dolibarr knowledge
- Modules 5-7 completed (frontend architecture and hooks)

## Backend Structure

```
monmodule/
├── pwa/
│   └── api.php                    # API entry point
├── smartmaker-api/
│   ├── Controllers/               # Business logic
│   │   └── ItemController.php
│   └── Mappers/                   # Dolibarr -> JSON conversion
│       └── dmItem.php
└── smartmaker-api-prepend.php     # Bootstrap
```

## Chapters

| # | Chapter | Content | |
| --- | --- | --- | --- |
| 1 | [Routing](/training/module8-backend-api/routage) | Configure routes in api.php |
| 2 | [Controllers](/training/module8-backend-api/controllers) | Business logic and CRUD |
| 3 | [Mappers](/training/module8-backend-api/mappers) | Convert Dolibarr to React |
| 4 | [Extrafields](/training/module8-backend-api/extrafields) | Dynamic forms and custom fields |

## Module Objectives

By the end of this module, you will know how to:

- Configure API routes
- Create controllers with complete CRUD
- Map Dolibarr objects to JSON
- Handle JWT authentication
- Use extrafields

## Request Flow

```
1. React: api.private.get('items/123')
           ↓
2. HTTP: GET /pwa/api.php?route=items/123
           ↓
3. api.php: Route to ItemController::show
           ↓
4. Controller: Load Dolibarr object
           ↓
5. Mapper: Convert to JSON
           ↓
6. api.php: Return JSON with HTTP code
```

## SmartAuth

JWT authentication is handled by SmartAuth:

- Automatic token validation
- Access to logged Dolibarr user
- Automatic token refresh

[Start: Routing ->](/training/module8-backend-api/routage)
