Files
JS/webseite-react-php/slim-php/README.md
Philippe Torrel 0bdbf245ee
2026-08-31 12:03:08 +02:00

29 lines
1.0 KiB
Markdown

Die MySQL-Datenbank und die Slim-REST-API sind eingerichtet und getestet.
**Datenbank `nerdshop`** (MAMP, Port 8889) enthält die Tabelle `products` mit den 13 Einträgen aus der JSON-Datei. Die Mongo-IDs bleiben als `id` erhalten; die API liefert sie als `_id`, damit die React-App kompatibel bleibt.
**API läuft auf** [http://localhost:8080](http://localhost:8080)
| Methode | URL | Status |
| -------- | ---------------- | ------------- |
| `GET` | `/products` | alle Produkte |
| `GET` | `/products/{id}` | ein Produkt |
| `POST` | `/products` | anlegen |
| `PUT` | `/products/{id}` | aktualisieren |
| `DELETE` | `/products/{id}` | löschen |
CORS ist für `http://localhost:5173` (Vite) gesetzt. In der React-App reicht später:
```js
fetch('http://localhost:8080/products');
```
Server neu starten:
```bash
cd slim-php-framework
php -S localhost:8080 -t public public/router.php
```
Falls MAMP andere Zugangsdaten nutzt, stehen sie in `slim-php-framework/.env`.