laravel-architecture
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLaravel Architecture
Laravel 架构
High-level architectural guidance for Laravel applications.
Laravel 应用的高阶架构指导。
Core Concepts
核心概念
philosophy.md - Foundational principles:
- Declarative code above all else
- Strict separation of concerns
- Type safety first
- All core architectural principles
patterns.md - Pattern overview:
- Actions for domain logic
- DTOs for data transfer
- State machines for complex state
- Services for external integration
- Workflows for multi-step processes
- Value objects for domain values
decisions.md - Pattern selection:
- When to use each pattern
- Decision flowcharts
- Architectural trade-offs
- Common scenarios
structure.md - Directory structure:
- Complete project organization
- File placement rules
- Namespace conventions
- Web vs API distinction
examples.md - Reference implementations:
- Complete working examples
- End-to-end workflows
- Real-world patterns
checklist.md - Implementation checklist:
- Setup tasks
- Feature development workflow
- Production deployment steps
philosophy.md - 基础原则:
- 优先使用声明式代码
- 严格关注分离
- 类型安全优先
- 所有核心架构原则
patterns.md - 模式概述:
- 用于领域逻辑的Actions
- 用于数据传输的DTOs
- 用于复杂状态的State machines
- 用于外部集成的Services
- 用于多步骤流程的Workflows
- 用于领域值的Value objects
decisions.md - 模式选择:
- 每种模式的适用场景
- 决策流程图
- 架构权衡
- 常见场景
structure.md - 目录结构:
- 完整项目组织方式
- 文件放置规则
- 命名空间约定
- Web与API的区别
examples.md - 参考实现:
- 完整可运行示例
- 端到端工作流
- 真实场景模式
checklist.md - 实施检查清单:
- 搭建任务
- 功能开发工作流
- 生产环境部署步骤
Core Principles
核心原则
- Actions contain domain logic - Business logic lives in invokable action classes
- Never pass primitives - Always use DTOs for data transfer
- Thin HTTP layer - Controllers only handle HTTP concerns
- Custom query builders - Type-safe queries over scopes
- Strict typing - in every file
declare(strict_types=1)
- Actions包含领域逻辑 - 业务逻辑存于可调用的Action类中
- 绝不传递原始类型 - 始终使用DTOs进行数据传输
- 精简HTTP层 - 控制器仅处理HTTP相关事宜
- 自定义查询构建器 - 优先使用类型安全查询而非scopes
- 严格类型检查 - 每个文件中添加
declare(strict_types=1)
Quick Decision Tree
快速决策树
Need to...
- Handle domain logic? → Action
- Transfer data? → DTO
- Validate user input? → Form Request
- Simple state field? → Enum
- Complex state transitions? → State Machine
- External API? → Service with Saloon
- Background processing? → Job (delegates to Action)
Read decision flowcharts in decisions.md for detailed guidance.
需要...
- 处理领域逻辑? → Action
- 传输数据? → DTO
- 验证用户输入? → Form Request
- 简单状态字段? → Enum
- 复杂状态转换? → State Machine
- 外部API? → 搭配Saloon的Service
- 后台处理? → Job(委托给Action)
如需详细指导,请阅读**decisions.md**中的决策流程图。