6.0 KiB
Symfony Framework Development Skill
Overview
This skill provides comprehensive guidance and tools for developing applications with Symfony 6.4, the leading PHP framework for web applications, APIs, and microservices.
Features
- Complete Symfony 6.4 Documentation: Core concepts, best practices, and advanced patterns
- Code Generation Scripts: Automated tools for entity and CRUD generation
- Deployment Automation: Production-ready deployment scripts
- Security Configurations: Advanced authentication and authorization patterns
- Performance Optimization: Caching strategies and query optimization techniques
- Testing Strategies: Unit, functional, and integration testing patterns
Structure
symfony-skill/
├── SKILL.md # Main skill file with core instructions
├── README.md # This file
├── LICENSE # MIT License
├── scripts/ # Automation scripts
│ ├── generate-entity.php # Entity generator
│ ├── generate-crud.php # CRUD generator
│ └── deploy.sh # Deployment automation
└── references/ # Detailed documentation
├── doctrine-advanced.md # Advanced ORM patterns
├── security-detailed.md # Security configurations
└── testing-complete.md # Testing strategies
Quick Start
Using the Skill
- Load the skill in your Claude conversation
- Reference specific topics when needed
- Use scripts for code generation tasks
- Check references for detailed documentation
Common Commands
# Create new Symfony project
symfony new my_project --version="6.4.*" --webapp
# Generate entity
php scripts/generate-entity.php Product name:string price:decimal
# Generate CRUD
php scripts/generate-crud.php Product
# Deploy application
./scripts/deploy.sh production main
Key Capabilities
1. Project Setup & Configuration
- Environment configuration
- Service container setup
- Bundle management
- Package installation
2. Development Patterns
- MVC architecture
- Dependency injection
- Event-driven programming
- Repository pattern
- Service layer pattern
3. Database & ORM
- Entity management
- Relationships mapping
- Query optimization
- Migration strategies
- Performance tuning
4. Security
- Authentication methods
- Authorization with voters
- JWT tokens
- OAuth integration
- Two-factor authentication
5. API Development
- RESTful APIs
- GraphQL integration
- API versioning
- Rate limiting
- CORS configuration
6. Testing
- Unit testing
- Functional testing
- Integration testing
- Test fixtures
- Mocking strategies
7. Performance
- Caching strategies
- Query optimization
- Asset optimization
- Profiling tools
- Production optimization
8. Deployment
- Environment preparation
- Automated deployment
- Zero-downtime deployment
- Rollback procedures
- Health checks
Usage Examples
Creating a New Feature
- Generate the entity:
php scripts/generate-entity.php Article title:string content:text author:relation:ManyToOne:User
- Create the CRUD:
php scripts/generate-crud.php Article
- Add business logic in services
- Write tests for the feature
- Deploy using the deployment script
API Development
- Create API controller using the --api flag:
php scripts/generate-crud.php Product --api
- Configure serialization groups in your entity
- Add validation rules
- Implement authentication
- Document with OpenAPI/Swagger
Best Practices
- Always use dependency injection - Never instantiate services manually
- Keep controllers thin - Move business logic to services
- Write tests first - Follow TDD approach for critical features
- Cache expensive operations - Use Symfony's cache component
- Optimize database queries - Use eager loading and query optimization
- Follow Symfony conventions - Use recommended directory structure and naming
- Use environment variables - For configuration that changes between environments
- Implement proper error handling - Use exceptions and proper HTTP status codes
- Document your code - Use PHPDoc and keep documentation updated
- Regular security updates - Keep dependencies updated and check for vulnerabilities
Common Issues & Solutions
Issue: Services not autowiring
Solution: Check service configuration and ensure autowiring is enabled
Issue: Database connection errors
Solution: Verify DATABASE_URL in .env file and database credentials
Issue: Cache permissions
Solution: Set proper permissions on var/cache directory
Issue: Route not found
Solution: Clear cache and check route configuration with debug:router
Issue: Migration failures
Solution: Check migration status and resolve conflicts manually if needed
Requirements
- PHP 8.1 or higher
- Composer
- Symfony CLI (recommended)
- Database (MySQL/PostgreSQL/SQLite)
- Web server (Apache/Nginx)
- Node.js & NPM (for assets)
Compatibility
- Symfony 6.4 LTS
- PHP 8.1, 8.2, 8.3
- MySQL 5.7+, PostgreSQL 10+, SQLite 3+
- Compatible with Docker environments
Contributing
This skill is designed to be extended. To add new capabilities:
- Update SKILL.md with new patterns
- Add scripts to scripts/ directory
- Create reference documentation in references/
- Test thoroughly before deployment
Support
For Symfony-specific questions:
- Official Documentation: https://symfony.com/doc/6.4/
- Symfony Slack: https://symfony.com/slack
- Stack Overflow: Tag with
symfony
Version History
- 1.0.0 - Initial release with Symfony 6.4 support
- Complete documentation coverage
- Entity and CRUD generators
- Deployment automation
- Advanced patterns documentation
License
MIT License - See LICENSE file for details
Credits
Created for Claude AI to enhance Symfony development capabilities. Based on official Symfony 6.4 documentation and community best practices.