Mini backend in plain PHP 8.2+ for storing and retrieving audio stories through a simple REST API.
stories-creator-server/
├── config/
│ ├── config.example.php # sample DB config
│ └── config.php # actual config (edit this)
├── database/
│ └── schema.sql # MySQL/MariaDB schema
├── public/
│ └── index.php # front controller / router
├── scripts/
│ └── create_tables.php # helper to run the schema via PDO
└── src/
├── Controllers/
│ └── StoryController.php
├── Database/
│ └── Connection.php
├── Models/
│ └── Story.php
├── Repositories/
│ └── StoryRepository.php
├── Router.php
└── helpers.php
GET /api→ elenco degli endpoint disponibiliGET /api/stories?limit=50&offset=0GET /api/stories/{id}POST /api/storiesPUT|PATCH /api/stories/{id}DELETE /api/stories/{id}
All responses are JSON (Content-Type: application/json). Errors follow { "error": "message" }.
- PHP 8.2+ with PDO MySQL extension enabled
- MySQL or MariaDB 10.x+
-
Install dependencies
- No Composer packages needed; ensure PHP has PDO MySQL.
-
Configure the database
cp config/config.example.php config/config.php
Edit
config/config.phpwith your DB credentials or set the env varsDB_HOST,DB_NAME, etc. -
Create the database schema
php scripts/create_tables.php
Alternatively run the SQL directly:
mysql -u your_user -p stories_creator < database/schema.sqlNota: all’avvio dell’API il server controlla automaticamente l’esistenza della tabella
storiese, se mancante o con colonne obsolete, applica lo schema richiesto. Lo script rimane utile per eseguire l’inizializzazione manuale o in ambienti CI.
php -S localhost:8000 -t publicThe API will be available at http://localhost:8000/api/stories.