This is a Laravel application used for demo purposes — a pseudo application that illustrates how SOLID principles can be applied in a PHP/Laravel codebase.
Recommended (Docker):
No local PHP or Composer installation is required when using Docker.
Application stack:
| Component | Version |
|---|---|
| PHP | 8.4 |
| Laravel | 13.x |
| MySQL | 8.4 |
PHP extensions (included in the Docker image; required if running without Docker):
pdo_mysql,mbstring,openssl,tokenizer,xml,ctype,json,bcmath,gd,zip
-
Clone the repository:
git clone git@github.com:SumonMSelim/solid-principles-example-laravel.git cd solid-principles-example-laravel -
Create your environment file:
cp .env.example .env
-
Configure Docker database settings in
.env(defaults matchdocker-compose.yml):APP_URL=http://localhost:8081 DB_CONNECTION=mysql DB_HOST=mysql DB_PORT=3306 DB_DATABASE=solid DB_USERNAME=solid DB_PASSWORD=secret
-
Build and start the containers:
docker compose up --build -d
-
Run database migrations:
docker compose exec app php artisan migrate -
(Optional) Verify the installation:
docker compose exec app php artisan test
Start all services:
docker compose up -dStop services:
docker compose downView logs:
docker compose logs -f appOpen the app at http://localhost:8081.
Health check: http://localhost:8081/up
Run the full test suite locally:
docker compose exec app php artisan testContinuous integration runs on every pull request and push to main via GitHub Actions.
| Service | URL / Port |
|---|---|
| App (nginx) | http://localhost:8081 |
| MySQL | localhost:3307 |
Default database credentials (override in .env):
- Database:
solid - Username:
solid - Password:
secret
Register a user via the API:
curl -X POST http://localhost:8081/api/users/create \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"first_name":"Jane","last_name":"Doe","email":"jane@example.com","password":"secret123"}'Check payment status:
curl http://localhost:8081/status| Method | Path | Description |
|---|---|---|
| GET | / |
Welcome page |
| POST | /register |
Register a user (web) |
| POST | /users/create |
Create a user (admin) |
| GET | /users/index |
List users from yesterday (admin) |
| POST | /pay |
Process a payment (user) |
| GET | /status |
Payment status (user) |
| POST | /api/register |
Register a user (API) |
| POST | /api/users/create |
Create a user (API) |
| Principle | Examples in this codebase |
|---|---|
| SRP | PaymentOrchestrator, NotificationService, CreateUserRequest |
| OCP | Payment gateways registered in config/payments.php; resolved via PaymentGatewayResolver |
| LSP | All payment classes implement PayableInterface; status services implement PaymentStatusInterface |
| ISP | Focused contracts: PayableInterface, NotifiableInterface, PaymentStatusInterface |
| DIP | Controllers depend on interfaces; bindings in AppServiceProvider |