PHPackages                             feruz/yii2-starter-v1 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. feruz/yii2-starter-v1

ActiveProject[Framework](/categories/framework)

feruz/yii2-starter-v1
=====================

Yii 2 Advanced Project Starter kids

v0.0.1(7mo ago)012BSD-3-ClausePHPPHP &gt;=8.3.0

Since Oct 3Pushed 7mo agoCompare

[ Source](https://github.com/feruzlabs/yii2-starter-v1)[ Packagist](https://packagist.org/packages/feruz/yii2-starter-v1)[ RSS](/packages/feruz-yii2-starter-v1/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (16)Versions (3)Used By (0)

Yii2 Advanced Template with Docker
==================================

[](#yii2-advanced-template-with-docker)

Complete Yii2 Advanced Template starter kit with Docker support, including API protection, monitoring, and microservices architecture.

🚀 Features
----------

[](#-features)

- **Yii2 Advanced Template** with API application
- **Docker-based** development and production environment
- **PHP 8.3** with PHP-FPM
- **Nginx** web server with optimized configuration
- **PostgreSQL 15** database
- **Redis 7** for caching and sessions
- **RabbitMQ 3.12** message broker
- **Supervisor** for background workers
- **API Protection:**
    - Priority-based rate limiting (Token Bucket)
    - Adaptive throttling (CPU/Memory based)
    - Circuit breaker pattern
    - Load shedding
- **Monitoring:**
    - PHP-FPM metrics
    - Application metrics
    - Alert system (Telegram, Email, Slack)
    - Health checks
- **Outbox Pattern** for reliable event publishing
- **Prometheus &amp; Grafana** support (optional)

📋 Prerequisites
---------------

[](#-prerequisites)

- Docker 20.10+
- Docker Compose 2.0+
- Make (optional, for convenience commands)

🛠️ Quick Start
--------------

[](#️-quick-start)

### 1. Clone and Initialize

[](#1-clone-and-initialize)

```
# Clone the repository
git clone
cd yii2-advanced-docker

# Copy environment file
cp .env.example .env

# Edit .env file with your configuration
nano .env

# Initialize and start services
make init
make up
```

Or without Make:

```
cp .env.example .env
docker-compose build
docker-compose up -d
docker-compose exec php-fpm php yii migrate --interactive=0
```

### 2. Access Services

[](#2-access-services)

- **Frontend:**
- **Backend:**
- **API:**
- **API Health:**
- **RabbitMQ Management:**  (guest/guest)
- **Prometheus:**  (with monitoring profile)
- **Grafana:**  (admin/admin, with monitoring profile)

### 3. Health Check

[](#3-health-check)

```
curl http://localhost:8082/health
```

📁 Project Structure
-------------------

[](#-project-structure)

```
yii2-advanced-docker/
├── api/                    # API application
│   ├── config/            # API configuration
│   ├── controllers/       # API controllers
│   └── web/               # Web root
├── common/                # Shared components
│   ├── components/        # Protection components
│   ├── behaviors/         # Behaviors
│   ├── models/           # Models
│   └── config/           # Common config
├── console/              # Console commands
│   └── controllers/      # Workers
├── docker/               # Docker configuration
│   ├── php-fpm/         # PHP-FPM config
│   ├── nginx/           # Nginx config
│   ├── postgresql/      # PostgreSQL config
│   ├── redis/           # Redis config
│   └── rabbitmq/        # RabbitMQ config
├── migrations/           # Database migrations
├── scripts/             # Utility scripts
├── docker-compose.yml   # Main compose file
├── Makefile            # Convenience commands
└── README.md

```

🔧 Configuration
---------------

[](#-configuration)

### Environment Variables

[](#environment-variables)

Key environment variables (see `.env.example` for full list):

```
# Database
DB_DSN=pgsql:host=pgsql;dbname=yii2advanced
DB_USERNAME=yii2
DB_PASSWORD=secret

# Redis
REDIS_HOST=redis
REDIS_PORT=6379

# RabbitMQ
RABBITMQ_HOST=rabbitmq
RABBITMQ_USER=guest
RABBITMQ_PASSWORD=guest

# Rate Limiting
RATE_LIMIT_USER_CAPACITY=100
RATE_LIMIT_USER_REFILL_RATE=10

# Throttling
THROTTLE_CPU_THRESHOLD=70
THROTTLE_MEMORY_THRESHOLD=80

# Alerts
ALERT_TELEGRAM_TOKEN=your_token
ALERT_TELEGRAM_CHAT_ID=your_chat_id
ALERT_EMAILS=admin@example.com
```

### Alert Configuration

[](#alert-configuration)

Edit `common/config/alerts.yml` to configure alert rules:

```
alerts:
  fpm_warning:
    severity: warning
    channels:
      - log
      - telegram
    throttle: 300  # seconds
```

🏃 Running Workers
-----------------

[](#-running-workers)

Workers are automatically started by Supervisor in the PHP-FPM container:

- **Outbox Processor** (2 instances) - Publishes events to RabbitMQ
- **FPM Monitor** - Monitors PHP-FPM health
- **Metrics Collector** - Collects application metrics
- **Alert Checker** - Checks alert conditions

View worker logs:

```
make logs-workers
# or
docker-compose exec php-fpm tail -f /var/log/supervisor/*.log
```

📊 Monitoring
------------

[](#-monitoring)

### View Metrics

[](#view-metrics)

```
curl http://localhost/api/monitoring/metrics
```

### View FPM Status

[](#view-fpm-status)

```
curl http://localhost/api/monitoring/fpm-status
```

### Alert History

[](#alert-history)

```
docker-compose exec php-fpm php yii alert/history
```

🧪 Testing
---------

[](#-testing)

### Create Test Order

[](#create-test-order)

```
curl -X POST http://localhost:8082/order/create \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": 1,
    "total_amount": 99.99,
    "items": [
      {"id": 1, "name": "Product 1", "price": 49.99, "quantity": 1},
      {"id": 2, "name": "Product 2", "price": 50.00, "quantity": 1}
    ]
  }'
```

### List Orders

[](#list-orders)

```
curl http://localhost:8082/order/index
```

### Test Rate Limiting

[](#test-rate-limiting)

```
for i in {1..100}; do curl http://localhost:8082/order/index; done
```

🐳 Docker Commands
-----------------

[](#-docker-commands)

### Using Makefile

[](#using-makefile)

```
make help              # Show available commands
make up                # Start all services
make down              # Stop all services
make restart           # Restart all services
make logs              # Tail all logs
make shell             # Shell into PHP container
make migrate           # Run migrations
make composer-install  # Install dependencies
make monitoring        # Start with monitoring stack
```

### Using Docker Compose Directly

[](#using-docker-compose-directly)

```
docker-compose up -d              # Start services
docker-compose down               # Stop services
docker-compose ps                 # List services
docker-compose logs -f            # Tail logs
docker-compose exec php-fpm sh    # Shell into PHP
```

🔨 Development
-------------

[](#-development)

### Run Migrations

[](#run-migrations)

```
make migrate
# or
docker-compose exec php-fpm php yii migrate
```

### Create Migration

[](#create-migration)

```
make migrate-create name=create_users_table
```

### Install Dependencies

[](#install-dependencies)

```
make composer-install
# or
docker-compose exec php-fpm composer install
```

### Access Database

[](#access-database)

```
make shell-db
# or
docker-compose exec pgsql psql -U yii2 -d yii2advanced
```

📈 Production Deployment
-----------------------

[](#-production-deployment)

### 1. Update Environment

[](#1-update-environment)

```
cp .env.example .env.production
# Edit .env.production with production settings
```

### 2. Build Production Images

[](#2-build-production-images)

```
docker-compose -f docker-compose.yml -f docker-compose.prod.yml build
```

### 3. Deploy

[](#3-deploy)

```
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
```

### 4. Security Checklist

[](#4-security-checklist)

- Change all default passwords
- Configure HTTPS/SSL certificates
- Set proper file permissions
- Configure firewall rules
- Enable security headers in Nginx
- Set up log rotation
- Configure backup strategy
- Set up monitoring alerts

🔍 Troubleshooting
-----------------

[](#-troubleshooting)

### Services Won't Start

[](#services-wont-start)

```
# Check logs
docker-compose logs

# Rebuild containers
docker-compose down
docker-compose build --no-cache
docker-compose up -d
```

### Database Connection Issues

[](#database-connection-issues)

```
# Check database is running
docker-compose ps pgsql

# Test connection
docker-compose exec php-fpm php yii migrate --interactive=0
```

### Permission Issues

[](#permission-issues)

```
# Fix permissions
docker-compose exec php-fpm chown -R www:www /var/www
```

### Worker Not Running

[](#worker-not-running)

```
# Check supervisor status
docker-compose exec php-fpm supervisorctl status

# Restart workers
docker-compose exec php-fpm supervisorctl restart all
```

📚 Documentation
---------------

[](#-documentation)

- [Yii2 Framework](https://www.yiiframework.com/doc/guide/2.0/en)
- [Docker Documentation](https://docs.docker.com/)
- [RabbitMQ Tutorials](https://www.rabbitmq.com/getstarted.html)
- [PostgreSQL Documentation](https://www.postgresql.org/docs/)

🤝 Contributing
--------------

[](#-contributing)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

📝 License
---------

[](#-license)

This project is licensed under the BSD-3-Clause License.

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- Yii2 Framework Team
- Docker Community
- All contributors

---

**Built with ❤️ using Yii2 and Docker**

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance64

Regular maintenance activity

Popularity3

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

221d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c80759bbba7d386d8820c86f973ee667455ca052580650868f4497f7ae6f53ec?d=identicon)[feruzlabs](/maintainers/feruzlabs)

---

Top Contributors

[![feruzostonov95](https://avatars.githubusercontent.com/u/22098386?v=4)](https://github.com/feruzostonov95 "feruzostonov95 (2 commits)")[![lycan333](https://avatars.githubusercontent.com/u/22098386?v=4)](https://github.com/lycan333 "lycan333 (2 commits)")[![victorTorotskiy](https://avatars.githubusercontent.com/u/117859926?v=4)](https://github.com/victorTorotskiy "victorTorotskiy (2 commits)")

---

Tags

frameworkdockeryii2advancedproject template

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/feruz-yii2-starter-v1/health.svg)

```
[![Health](https://phpackages.com/badges/feruz-yii2-starter-v1/health.svg)](https://phpackages.com/packages/feruz-yii2-starter-v1)
```

###  Alternatives

[yiisoft/yii2-app-advanced

Yii 2 Advanced Project Template

1.7k957.7k5](/packages/yiisoft-yii2-app-advanced)[razonyang/yii2-app-template

Yii2 App Project Template

262.8k](/packages/razonyang-yii2-app-template)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
