Skip to content

supravatm/laravel-v12-api-starter

Repository files navigation

Laravel 12.x Rest API Starter Kit with Docker

Laravel + Docker

A Laravel & Docker Development Setup

Features

  • Laravel 12 REST API starter, ready for develop and customization.
  • Dockerized environment: PHP-FPM , Nginx, MySQL, phpMyAdmin, and Mailhog.
  • Easy setup with Docker Compose.
  • Postman API documentation link for quick reference.

Services Overview (docker-compose.yaml)

Service Description Ports Healthcheck
app PHP-FPM container for Laravel - Yes (depends on DB)
nginx Web server serving the application 80:80 -
database MySQL 8.0 database 3306:3306 Yes
phpmyadmin Database management UI 8888:80 Yes (depends on DB)
mailpit Email testing tool (SMTP + web UI) 1025:1025, 8025:8025 Yes

Quick Start

1. Clone the Repository

git clone git@github.com:supravatm/laravel-v12-api-starter.git
cd laravel-v12-api-starter

2. Install Dependencies

docker run --rm -v "$(pwd)":/app composer install

3. Configure Environment Variables

Update your .env file for database credential:

DB_CONNECTION=mysql
DB_HOST=database
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=user
DB_PASSWORD=password

4. Start Containers

docker-compose up -d

Note: Some containers wait for the database service to be healthy before starting.

5. Laravel Setup

Run the following initialization commands:

docker-compose exec app php artisan key:generate
docker-compose exec app php artisan optimize
docker-compose exec app php artisan session:table
docker-compose exec app php artisan migrate
docker-compose exec app php artisan cache:clear

Accessing Services


Email Testing

Mailpit is use for email testing. It stores messages and provides a web interface to view sent emails.
No extra configuration needed for Laravel; just set the following in your .env:

MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

API Testing

Preview


Complete REST API Documentation can be found here

Troubleshooting

  • Ensure Docker Desktop (or Docker Engine) is running.
  • If containers fail to start, use docker-compose logs for details.
  • Database and phpMyAdmin may take a moment to become healthy.

License

MIT