Skip to content
analyze-yii2-project logo

Analyze Yii2 Project Workflow

analyze-yii2-project

Use this when user provides a Yii2 codebase for analysis or migration planning. Provides 6-phase workflow: scan, capability extraction, dependency analysis, requirements extraction, semantic indexing, and migration roadmap. Apply when user mentions Yii2, PHP legacy modernization, or framework mig...

mattnigh/skills_collection0installs24stars

SKILL.md

Full skill instructions

Analyze Yii2 Project Workflow

Purpose

Comprehensive workflow for analyzing legacy Yii2 projects to extract business logic, understand architecture, and plan modernization.

When to Use

  • ✅ User provides Yii2 codebase for analysis
  • ✅ Planning Yii2 → NestJS/​Modern framework migration
  • ✅ Need to understand undocumented Yii2 project
  • ✅ Extracting business requirements from Yii2 code
  • ✅ Technical debt assessment of Yii2 application

Prerequisites

Infrastructure Check

codecompass health

Verify:

  • ✅ Weaviate running (localhost:8081)
  • ✅ Ollama running (localhost:11434)
  • ✅ PostgreSQL running (localhost:5433)

Project Requirements

  • Yii2 project directory accessible
  • vendor/ directory present (run composer install if missing)
  • Read permissions on all files

Step-by-Step Workflow

Phase 1: Initial Scan (Quick Overview)

Step 1.1: Run Yii2 Analyzer

codecompass analyze:yii2 <path-to-yii2-project>

What this does:

  • Scans directory structure
  • Detects Yii2 version
  • Identifies conventions (controllers, models, views)
  • Extracts routing patterns
  • Maps database migrations

Expected output:

  • Framework version
  • Directory structure validation
  • Controller/​Model counts
  • Migration history

Step 1.2: Validate Results Check for:

  • ❌ Missing vendor/ → Run composer install
  • ❌ Old Yii2 version (<2.0.40) → Check compatibility notes in docs/​YII2_QUICK_REFERENCE.md
  • ❌ Non-standard structure → May need manual configuration

Phase 2: Business Capability Extraction

Step 2.1: Extract Controllers → Capabilities

# Analyzer automatically extracts business capabilities from controllers

What this maps:

Controller → Business Capability
├── UserController → User Management
├── OrderController → Order Processing
├── PaymentController → Payment Handling
└── ReportController → Reporting & Analytics

Step 2.2: Extract Models → Domain Entities Identifies:

  • ActiveRecord models → Database entities
  • Validation rules → Business rules
  • Relationships → Domain model connections

Step 2.3: Extract Migrations → Data Model Evolution Traces:

  • Schema changes over time
  • Business logic embedded in migrations
  • Data transformation patterns

Phase 3: Dependency Analysis

Step 3.1: Analyze Class Dependencies Uses: AstAnalyzerService for PHP parsing

Maps:

  • Tight coupling (classes depending on many others)
  • Circular dependencies (refactoring red flags)
  • Inheritance hierarchies
  • Service dependencies

Step 3.2: Identify Core vs Supporting Logic Categorizes:

  • Core Domain: Business-critical logic (preserve carefully)
  • Supporting: Infrastructure, utilities (can be replaced)
  • Generic: Framework boilerplate (discard in migration)

Phase 4: Requirements Extraction

Step 4.1: Run Requirements Extractor

codecompass requirements:extract --project-id <yii2-project-id>

Extracts:

  • Validation rules from models → Business constraints
  • Controller actions → Use cases
  • RBAC rules (if present) → Authorization requirements
  • Database constraints → Data integrity rules

Step 4.2: Generate Documentation Outputs:

  • Business capability map (Markdown)
  • Domain model diagram (Mermaid)
  • Use case catalog
  • Data dictionary

Phase 5: Semantic Indexing (Optional but Recommended)

Step 5.1: Index Codebase

codecompass batch:index <path-to-yii2-project>

Why:

  • Enables semantic search for "business logic for payment processing"
  • Cross-file pattern discovery
  • Similar code detection
  • Natural language queries

Step 5.2: Verify Indexing

curl http://localhost:8081/​v1/​schema
# Check for CodeContext or AtlasCode collection

Step 5.3: Test Semantic Search

codecompass search:semantic "validation rules for customer registration"

Should return: User model validators, controller logic, related code

Phase 6: Migration Planning

Step 6.1: Identify Migration Complexity Assess:

  • Low complexity: CRUD operations, standard patterns
  • Medium complexity: Custom workflows, business rules
  • High complexity: Legacy integrations, undocumented logic

Step 6.2: Prioritize by Business Value Map:

Business Capability → Migration Priority
├── Core Revenue Generating → HIGH (do first, carefully)
├── Customer-Facing → MEDIUM (visible impact)
└── Internal Tools → LOW (can defer)

Step 6.3: Generate Migration Roadmap Structure:

  1. Infrastructure setup (NestJS, TypeORM, etc.)
  2. Domain models (migrate ActiveRecords → TypeORM entities)
  3. Core business logic (preserve carefully)
  4. API layer (REST/​GraphQL endpoints)
  5. Background jobs (if using Yii2 queue)
  6. Testing & validation

Common Patterns to Look For

Yii2 Controller Patterns

// CRUD pattern
public function actionIndex() // → LIST endpoint
public function actionView($id) // → GET/:id endpoint
public function actionCreate() // → POST endpoint
public function actionUpdate($id) // → PUT/:id endpoint
public function actionDelete($id) // → DELETE/:id endpoint

Maps to NestJS:

@Controller('users')
export class UsersController {
  @Get() findAll()
  @Get(':id') findOne()
  @Post() create()
  @Put(':id') update()
  @Delete(':id') remove()
}

Yii2 Model Patterns

// Validation rules
public function rules() {
  return [
    [['email'], 'required'],
    [['email'], 'email'],
  ];
}

Maps to NestJS DTO:

export class CreateUserDto {
  @IsNotEmpty()
  @IsEmail()
  email: string;
}

Yii2 Database Patterns

// ActiveRecord query
$users = User::find()
  ->where(['status' => User::STATUS_ACTIVE])
  ->orderBy('created_at DESC')
  ->all();

Maps to TypeORM:

const users = await this.userRepository.find({
  where: { status: UserStatus.ACTIVE },
  order: { createdAt: 'DESC' },
});

Output Artifacts

1. Architecture Diagram (Mermaid)

graph TD
  Controller[Controllers] --> Service[Business Logic]
  Service --> Model[ActiveRecord Models]
  Model --> DB[(Database)]
  Controller --> View[Views]

2. Business Capability Map

## Core Capabilities
- User Management (UserController, User model)
- Order Processing (OrderController, Order/​OrderItem models)
- Payment Handling (PaymentController, Payment model)

## Supporting Capabilities
- Reporting (ReportController)
- Notifications (EmailService)

3. Migration Checklist

  • Set up NestJS project structure
  • Migrate database schema (Yii2 migrations → TypeORM migrations)
  • Port models (ActiveRecord → TypeORM entities)
  • Reimplement business logic (preserve rules!)
  • Create API endpoints (REST/​GraphQL)
  • Port authentication/​authorization
  • Migrate background jobs
  • Integration testing
  • Performance testing
  • Gradual rollout

Common Issues & Solutions

Issue 1: Cannot find controllers

Symptom: Analyzer reports 0 controllers Cause: Non-standard directory structure Solution: Check @app alias configuration in Yii2, adjust paths

Issue 2: Missing database schema

Symptom: Cannot extract models properly Cause: Database not accessible or migrations not run Solution: Ensure database connection configured, run pending migrations

Issue 3: Circular dependencies detected

Symptom: Dependency graph shows circular references Meaning: Code smell - tight coupling between modules Action: Plan refactoring to break cycles during migration

Issue 4: Undocumented business rules

Symptom: Complex logic in controllers with no comments Action:

  1. Use semantic search to find similar patterns
  2. Interview original developers if available
  3. Write tests to capture behavior before migration
  4. Document assumptions in requirements docs

Best Practices

✅ Do

  • Run full analysis before planning migration
  • Extract ALL business rules (even implicit ones)
  • Document assumptions and unknowns
  • Test semantic search to validate indexing
  • Create comprehensive capability map
  • Prioritize by business value, not technical ease

❌ Don't

  • Skip dependency analysis (will bite you later)
  • Assume standard Yii2 patterns everywhere
  • Ignore validation rules (they're business requirements!)
  • Start coding before understanding full architecture
  • Migrate everything at once (strangler fig pattern instead)

Related Skills

  • extract-requirements.md - For detailed requirements extraction
  • semantic-search.md - For code exploration
  • software-architect.md - For architecture perspective

Related Modules

From .ai/​capabilities.json:

  • yii2-analyzer - Main analysis module
  • ast-analyzer - PHP parsing
  • database-analyzer - Schema extraction
  • requirements - Business rules extraction
  • business-analyzer - Capability mapping

Remember: The goal is not just to understand the code, but to preserve the business knowledge embedded in it.

More skills from mattnigh

spring-framework-patterns logo
mattnigh/skills_collection

spring-framework-patterns

Comprehensive Spring Framework and Spring Boot best practices including dependency injection patterns, bean lifecycle and scopes, REST API development, Spring Data JPA, service layer design, Spring Security, testing strategies, caching, AOP, async processing, error handling, and common anti-patte...

24 0
View

TypeScript厳格モードによる型安全性設計を専門とするスキル。 📖 参照書籍: - 『Effective TypeScript』(Dan Vanderkam): 型設計 📚 リソース参照: - `resources/Level1_basics.md`: レベル1の基礎ガイド - `resources/Level2_intermediate.md`: レベル2の実務ガイド - `resources/Level3_advanced.md`: レベル3の応用ガイド - `resources/Level4_expert.md`: レベル4の専門ガイド - `resources/di...

24 0
View
deploying-cloud-k8s logo
mattnigh/skills_collection

deploying-cloud-k8s

Deploys applications to cloud Kubernetes (AKS/GKE/DOKS) with CI/CD pipelines. Use when deploying to production, setting up GitHub Actions, troubleshooting deployments. Covers build-time vs runtime vars, architecture matching, and battle-tested debugging.

24 0
View
moai-alfred-agent-guide logo
mattnigh/skills_collection

moai-alfred-agent-guide

19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.

24 0
View
mermaid-diagram-generator logo
mattnigh/skills_collection

mermaid-diagram-generator

Converts architecture descriptions, module specs, or workflow docs into Mermaid diagrams. Use when visualizing brick module relationships, workflows (DDD, investigation), or system architecture. Supports: flowcharts, sequence diagrams, class diagrams, state machines, entity relationship diagrams,...

24 0
View
pre-flight-check logo
mattnigh/skills_collection

pre-flight-check

INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.

24 0
View
browser-dev-tools logo
mattnigh/skills_collection

browser-dev-tools

This skill should be used when working with browser-rendered artifacts (i.e. Bun, React/React Native) to proactively validate that development work on localhost is being built appropriately and to support debugging browser-rendered content. Use this skill after making frontend changes to verify t...

24 0
View
lead-dev logo
mattnigh/skills_collection

lead-dev

Lead Développeur - Coordination technique opérationnelle, code review, mentoring et livraison. Pair de web-dev-process au niveau OPÉRATIONS.

24 0
View
worker-monitor logo
mattnigh/skills_collection

worker-monitor

Monitor Docker workers, RQ queue health, and auto-scale workers (max 4). Use when: checking job progress, monitoring queue depth, scaling workers up/down, diagnosing slow processing, or waiting for jobs to complete. Referenced by data-quality skill during reprocessing.

24 0
View
quality-advisor logo
mattnigh/skills_collection

quality-advisor

Proactive quality guidance system that monitors artifact creation and provides real-time feedback on documentation quality

24 0
View
bump-version logo
mattnigh/skills_collection

bump-version

This skill should be used when the user wants to bump the version number in the workspace. It updates versions across all pyproject.toml files (root, tde, and tda packages) and the CHANGELOG.md to keep them synchronized.

24 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View