PHP-CRUD-API with Apache proxy support and a short /api/ route to database records.
618
REST API container derived from mevdschee/php-crud-api, with small Apache customizations for Softfour deployments.
proxy and proxy_http modules.ProxyPass /api/ http://localhost/api.php/records/, so /api/posts maps to /api.php/records/posts.php_value error_reporting 1 to the application's .htaccess.Database drivers, query syntax, controllers and middleware come from upstream. This image does not create a database or provision a schema.
| Tag | Base | Published platform |
|---|---|---|
latest | mevdschee/php-crud-api:latest | linux/amd64 |
Checked on 2026-11-08. Both the Softfour tag and the upstream base tag can move; pin a digest for repeatable deployments. No native ARM64 variant is currently advertised.
This example connects to an existing MySQL-compatible database. Create a local .env file containing DB_HOST, DB_NAME, DB_USER and DB_PASSWORD. Use a database account limited to the operations and tables your API needs. Set DB_TABLES to a comma-separated list of tables to expose, for example posts.
services:
crud-api:
image: softfour/crud-api:latest
restart: unless-stopped
ports:
- "127.0.0.1:8080:80"
environment:
PHP_CRUD_API_DRIVER: "mysql"
PHP_CRUD_API_ADDRESS: "${DB_HOST:?Set DB_HOST}"
PHP_CRUD_API_PORT: "${DB_PORT:-3306}"
PHP_CRUD_API_DATABASE: "${DB_NAME:?Set DB_NAME}"
PHP_CRUD_API_USERNAME: "${DB_USER:?Set DB_USER}"
PHP_CRUD_API_PASSWORD: "${DB_PASSWORD:?Set DB_PASSWORD}"
PHP_CRUD_API_TABLES: "${DB_TABLES:?Set DB_TABLES to the tables to expose}"
docker compose config --quiet
docker compose up -d
docker compose logs --tail=100 crud-api
curl --fail-with-body http://127.0.0.1:8080/api/posts
The request assumes an existing permitted posts table. Replace it with your table name. DB_HOST must resolve and be reachable from the container; localhost inside the container refers to that container, not the Docker host. The example publishes HTTP only on the host's loopback interface and does not configure API authentication.
| Variable | Default or requirement | Purpose |
|---|---|---|
PHP_CRUD_API_DRIVER | Upstream default mysql | Database driver; upstream also supports pgsql, sqlsrv and sqlite |
PHP_CRUD_API_ADDRESS | Upstream default localhost | Database hostname, or database file for SQLite |
PHP_CRUD_API_PORT | Driver default | Database TCP port |
PHP_CRUD_API_DATABASE | Required for the example | Database name |
PHP_CRUD_API_USERNAME | Required for the example | Database user |
PHP_CRUD_API_PASSWORD | Required for the example | Database password |
PHP_CRUD_API_TABLES | Upstream exposes all tables unless restricted | Comma-separated table allowlist |
PHP_CRUD_API_MIDDLEWARES | Upstream default cors | Middleware selection, including authentication and authorization options |
See the upstream configuration reference for the complete option set. Features depend on the upstream version bundled into the selected image.
Apache listens on container port 80. The short /api/ route maps only to the records controller; use upstream paths for other enabled controllers. The proxy target uses HTTP on localhost inside the container.
The example uses an external database, so database persistence and backup belong to that database deployment. A SQLite deployment needs a separate persistent, writable mount and matching database-file configuration.
Configure API authentication, authorization, table restrictions and TLS termination before granting remote access. Database credentials alone are not API-client authentication. Keep .env and other secret files out of version control; container environment variables can be read by Docker administrators. Avoid printing expanded Compose configuration when handling real secrets.
docker compose ps
docker compose logs --tail=100 crud-api
For connection failures, check database DNS, port, user privileges and network access. For missing tables, check the schema, allowlist and request path. For unexpected API behavior, compare against the documentation for the bundled upstream version. Redact credentials and database contents before sharing logs.
Back up the database and record the current image digest before upgrading:
docker compose pull crud-api
docker compose up -d crud-api
Verify representative read and write operations against a test database before promoting a changed upstream version. To roll back, use the previous softfour/crud-api@sha256:... digest and matching configuration; database changes may require a matching database restore.
Maintained by Softfour. For support, use your existing Softfour support channel and include the image tag, digest, platform and relevant logs with credentials removed.
The repository README is the source for this Docker Hub overview. Documentation updates do not change image contents. No versioned image changelog is currently published; record the digest before upgrading.
PHP-CRUD-API is published under the upstream MIT license; Apache, PHP and other bundled components have their own licenses. Third-party components retain their respective licenses. Contact Softfour for licensing information about image-specific files.
Content type
Image
Digest
sha256:8d5a2504d…
Size
174.2 MB
Last updated
about 10 hours ago
docker pull softfour/crud-api