A Slim 4 REST API starter in PHP 8.2 for PHP developers who want a small JSON API with PSR-7 requests and responses. It includes single-action route classes, a health check, PHPUnit tests and a Dockerfile on the official PHP Apache image.
by Light CloudREST APIs
Requests go from Apache (or PHP's built-in server via composer start) to public/index.php, which loads the app from config/bootstrap.php; the routing middleware then hands the PSR-7 request to the matching action class. Because PHP starts fresh for every request, the uptime in /health stays close to zero, so most people adapt or drop that field first, then add their own actions and, for POST bodies, addBodyParsingMiddleware(). The repo includes a .mcp.json for the Light Cloud MCP server, and Light Cloud builds the Dockerfile and redeploys on each push to your copy.
Add an invokable class in src/Action/ that takes the request and response and returns the response, like HomeAction.php. Register it in config/routes.php with $app->get('/path', YourAction::class).
Add $app->addBodyParsingMiddleware(); in config/bootstrap.php. $request->getParsedBody() then returns the decoded JSON as an array.
Slim's error middleware picks the format from the Accept header. Send Accept: application/json and errors, including the 404 for unknown routes, come back as JSON.
Slim gives you routing, middleware and PSR-7 and nothing else, which suits small APIs and services. Laravel brings an ORM, queues and much more, which pays off on larger apps.
Yes. Run composer install --no-dev and point the document root at public/: Apache uses the included .htaccess, and on nginx use try_files $uri /index.php?$query_string. The Docker image runs on any container host too.
Start a Node.js REST API with Express, CORS, JSON errors and tests already wired up
Start a small Ruby JSON API with Sinatra, without Rails or a database
Deploy an app in any language: bring a Dockerfile that listens on PORT