gighiveThis document describes the current, implemented API behavior under
ansible/roles/docker/files/apache/webroot and outlines planned enhancements.
High-level best practices followed here:
src/ – MVC controllers, services, repositories, models, and the router/front controller live under src/ and are loaded via Composer./api/... (and other webroot paths) – clients call /api/... and /db/... URLs, which are small entrypoints, not the bulk of the application logic.src/index.php acts as a front controller/router that receives requests from thin entrypoints (such as /api/uploads.php) and dispatches them into the MVC stack.The Apache webroot for the API and UI is:
ansible/roles/docker/files/apache/webroot/Key subdirectories relevant to the API:
/api/
uploads.php is active, and it
exists as a thin compatibility shim that forwards into the router
implemented under src/./src/
src/index.php) that handles API routing
for uploads and, in future, additional endpoints./db/
/src/index.php)The main Router lives in:
src/index.phpResponsibilities:
Database, UploadController)./src or /api prefixes.POST /src/uploads → UploadController::post($_FILES, $_POST)GET /src/uploads/{id} → UploadController::get($id)POST /api/uploads and GET /api/uploads/{id} are also supported,
because the router strips both /src and /api prefixes.Content-Type: application/json).ui=html or Accept prefers text/html and
the request is POST), renders a minimal HTML confirmation page with
a link back to /db/database.php.[SRC_ROUTER_DEBUG]) to help trace routing.Net effect: All modern upload behavior is implemented in the MVC layer and
routed through src/index.php.
/api/uploads.php)File:
api/uploads.phpCurrent behavior:
/api/uploads.php working while delegating to the new MVC router.$_SERVER['REQUEST_URI'] to a normalized /api/uploads...
form and then includes ../src/index.php.Result:
/api/uploads.php are ultimately handled by the same
UploadController logic used by /src/uploads./api/uploads.php./db/)There are two main upload forms under /db/:
db/upload_form.phpaction="/api/uploads.php"db/upload_form_admin.phpaction="/api/uploads.php"Important notes:
/api/uploads.php./api/uploads.php is now a shim into src/index.php, the
submissions are handled by the MVC upload logic.docs/API_CLEANUP.md suggested changing these
actions to /src/uploads, but that specific change has not yet been
applied. Compatibility is provided instead via the shim./db/database.php)File:
db/database.phpBehavior (high level):
?format=json query parameter for JSON responses.GET /database.php
path (for JSON list behavior).Note:
database.php remains the
current, canonical implementation for listing media in both HTML and JSON
formats.The Swagger/OpenAPI documentation is served as static files under:
docs/api-docs.html — Swagger UI HTML shell.docs/openapi.yaml — OpenAPI 3.0.3 specification.Key points:
api-docs.html loads Swagger UI from a CDN and points it at
./openapi.yaml.openapi.yaml is a hand-maintained spec and describes:
POST /uploads (upload endpoint).GET /uploads/{id}.GET /database.php with ?format=json behavior./src/index.php and related
files).The docs/API_CLEANUP.md plan outlined a migration from the legacy
/api/uploads.php script into a centralized MVC router and then toward
cleaner, REST-style API URLs. That migration has largely happened at the
implementation level (via src/index.php), while /api/uploads.php
remains as a backward-compatible entrypoint.
What has been implemented:
src/index.php and handles upload routes.api/uploads.php is now a thin shim that delegates into
src/index.php, so legacy /api/uploads.php calls and canonical
/api/uploads / /api/uploads/{id} URLs all share the same
UploadController logic.What remains from the original plan:
/db/ still post to /api/uploads.php instead of
the canonical /api/uploads endpoint./api/ directory and uploads.php shim are still present and
active; final cleanup/deletion has not yet occurred.Why prefer the canonical endpoints directly (/api/uploads,
/api/uploads/{id}):
/api/uploads.php shim can be removed with minimal risk.This document reflects the actual, deployed state, not just the plan,
and treats /api/uploads / /api/uploads/{id} as the preferred public
API URLs for uploads today.
/api/uploads.php and /api/Goal:
/src/ (and future /media-files)
while preserving compatibility during a transition period.Planned steps:
/src/uploads
action in db/upload_form.php and db/upload_form_admin.php:
/api/uploads.php/src/uploadssrc/index.php is
already the canonical handler for uploads)./api/uploads.php as a legacy alias temporarily
/api/uploads.php continue to work.docs/openapi.yaml, mark the /uploads (or /api/uploads.php)
path as deprecated: true once the new naming is introduced (see 7.2)./api/uploads.php:
api/uploads.php./api/ directory if it has no other responsibilities./api/media-files GET/POST EndpointsGoal:
/api prefix:
POST /api/media-files — upload a media file.GET /api/media-files — list media files (JSON).Design principles:
src/index.php)
POST /api/media-files and GET /api/media-files./api prefix, it will match
on /media-files and:
POST /media-files → same behavior as POST /uploads today.GET /media-files → same JSON list behavior as
GET /database.php?format=json./media-files routes and the existing routes
both calling into the same functions/services./src/uploads (and /api/uploads.php during the
deprecation period)./db/database.php and /db/database.php?format=json./api/... paths already require Basic Auth (Require valid-user) via the main LocationMatch in default-ssl.conf./api/uploads.php and /api/media-files have a stricter Location block that limits access to admin and uploader users.modsecurity.conf.j2) is configured so that the upload-specific rules (large body limit, multipart/form-data requirement, disallowed extensions) apply to both /api/uploads.php and /api/media-files.openapi.yaml
POST /api/media-files
operationId: uploadMediaFile.GET /api/media-files
database.php?format=json returns today.operationId: getMediaFileList./database.php list path in
openapi.yaml, add deprecated: true once /media-files is present
and documented as the preferred interface./media-files is the preferred
endpoint for new integrations./docs (e.g., upload options, request
flow diagrams) to reference /media-files as the primary API.POST /media-files for uploads.GET /media-files for listings.deprecated endpoints in a future major version, orThis document is intended to be the authoritative reference for what is currently implemented in the webroot API and how we plan to evolve it toward cleaner, REST-style endpoints while maintaining backward compatibility.