START: Should I migrate my PHP app to Python? +-- Is your PHP app actively maintained and working well? | +-- YES -> Consider staying with PHP. Migration has real cost. Only proceed if | | there's a strategic reason (team skills, ecosystem needs, ML/AI integration). | +-- NO v +-- Do you need ML/AI, data science, or scientific computing? | +-- YES -> Migrate to Python (Django/Flask/FastAPI). Python's ecosystem is unmatched. [src8] | +-- NO v +-- Is the codebase > 100K lines of PHP? | +-- YES -> Use Strangler Fig pattern. Run both side-by-side. -> See Step 4 [src6] | +-- NO v +-- Do you need a full-featured admin, ORM, auth out of the box? | +-- YES -> Choose Django -> See Code Example 1 [src4] | +-- NO v +-- Need a lightweight microservice or API? | +-- YES -> Choose Flask or FastAPI -> See Code Example 2 [src2, src8] | +-- NO v +-- DEFAULT -> Django (batteries-included is safer for most migrations) [src3] Framework choice: +-- Need admin panel, user management, ORM, forms? | +-- YES -> Django [src4] +-- Need maximum flexibility, minimal overhead? | +-- YES -> Flask [src2] +-- Need async-first, high-performance API, auto-generated OpenAPI docs? | +-- YES -> FastAPI [src8] +-- Migrating from Laravel specifically? | +-- YES -> Django (closest conceptual match to Laravel) [src3] App size considerations: +-- Small (<10K lines) | +-- Clean rewrite in Django/Flask/FastAPI is feasible (2-4 weeks) +-- Medium (10K-100K lines) | +-- Use strangler fig. Estimate 2-6 months incremental migration. +-- Large (>100K lines) | +-- Use strangler fig with dedicated team. Estimate 6-18 months. | +-- Consider migrating API layer only, keep PHP for legacy UI.