yii2-patterns

Enforce clean controller boundaries and explicit validation in Yii2 applications.

1|Updated Aug 6, 2025
One-click install
npx skills add https://github.com/vix-4800/Workstation --skill yii2-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: yii2-patterns
Source: https://github.com/vix-4800/Workstation/tree/main/roles/ai-tools/files/agents/skills/yii2-patterns
Command: npx skills add https://github.com/vix-4800/Workstation --skill yii2-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Yii2 architecture consistency: it guides how to structure controllers, models, services, and AR usage to keep code maintainable and testable.

Core Features & Use Cases

  • Clear separation of concerns between controllers, models, and services.
  • Emphasis on explicit validation through forms or DTO-like objects.
  • Guidance for RBAC and authorization checks, and for review of AR usage patterns.

Quick Start

Apply these patterns to an existing Yii2 project to improve controller simplicity and validation boundaries.

Frequently Asked Questions about yii2-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I keep Yii2 controllers thin and move validation to form models?

To keep Yii2 controllers thin, enforce clear separation of concerns by using form or request models for explicit validation, ensuring controllers only handle flow while validation logic stays in dedicated DTO-like objects.

What is the best way to structure Active Record queries for maintainability in Yii2?

The best way to structure Active Record queries in Yii2 is to enforce explicit transaction boundaries and clear query patterns, controlling AR usage to keep database interactions maintainable during code audits.

How does RBAC authorization fit into clean architecture for a Yii2 backend app?

RBAC authorization fits into Yii2 clean architecture by acting as an explicit boundary within thin controllers, separating permission checks from business logic to keep services and models focused.

Can I apply these Yii2 architecture patterns during a code review of existing modules?

Yes, you can apply these Yii2 architecture patterns during code reviews and refactoring of existing modules, guiding audits across controllers, models, and services to improve structural consistency and testability.

When should I use explicit mappers instead of Active Record for validation in Yii2?

You should use explicit mappers instead of Active Record in Yii2 when you need strict validation boundaries, separating data persistence from input validation to keep controllers thin and AR usage controlled.