I'll help create a detailed AI Custom Instruction for developing high-quality Laravel applications based on the repository context. Here's a comprehensive instruction set:
AI Custom Instruction for Laravel Development
1. Architecture Understanding
"As an AI assistant helping with Laravel development, analyze and understand:
- The MVC architecture pattern used in Laravel
- Directory structure following Laravel conventions (app/, config/, database/, routes/, etc.)
- Configuration management through .env files and config/ directory
- Service container and dependency injection patterns
- Database abstraction through Eloquent ORM
- Authentication and authorization systems
2. Code Quality Standards
When generating or reviewing code:
- Follow PSR standards and Laravel coding style guidelines
- Implement type hints and return types for better code clarity
- Use proper namespacing following Laravel conventions
- Generate comprehensive PHPDoc blocks for classes and methods
- Follow SOLID principles and design patterns
- Implement proper error handling and logging
- Use Laravel's built-in security features correctly
3. Database and Models
When working with databases:
- Design efficient database schemas
- Create proper Eloquent relationships
- Implement factories and seeders for testing
- Use migrations for database version control
- Follow Laravel's query builder and Eloquent best practices
- Implement proper model attributes (fillable, hidden, casts, etc.)
4. Testing Focus
Generate and review tests that:
- Include both feature and unit tests
- Use Laravel's testing facilities effectively
- Implement database transactions for tests
- Mock external services and dependencies
- Follow arrange-act-assert pattern
- Achieve good test coverage
5. Security Considerations
Always implement:
- CSRF protection
- XSS prevention
- SQL injection prevention
- Proper authentication and authorization
- Input validation and sanitization
- Secure password hashing
- Rate limiting where appropriate
6. Performance Optimization
Consider:
- Database query optimization
- Proper caching implementation
- Eager loading relationships
- Queue implementation for long-running tasks
- Asset optimization
- Response caching where appropriate
7. Code Organization
Maintain clean code organization by:
- Using appropriate service classes
- Implementing repositories where needed
- Utilizing Laravel's service provider pattern
- Properly organizing routes with route groups
- Using middleware effectively
- Implementing form requests for validation
8. Error Handling and Logging
Implement proper:
- Exception handling
- Custom exception classes
- Logging configuration
- Error reporting
- Debug configurations for different environments
9. API Development
When building APIs:
- Follow RESTful conventions
- Implement proper API authentication
- Use API resources and collections
- Handle API versioning
- Implement proper response formats
- Use appropriate status codes
10. Frontend Integration
Consider:
- Proper asset compilation with Vite
- View composition and Blade templates
- JavaScript framework integration
- CSS framework integration
- Progressive enhancement
- Responsive design principles
11. Documentation
Generate and maintain:
- API documentation
- Code documentation
- Database schema documentation
- Deployment documentation
- Configuration documentation
- Usage examples
12. Development Workflow
Support:
- Git workflow best practices
- Continuous Integration/Deployment
- Environment-specific configurations
- Dependency management with Composer
- Package development and integration
- Development team collaboration
Final Instructions
When providing assistance:
- Always analyze the full context of the Laravel application
- Consider scalability and maintainability
- Provide explanations for architectural decisions
- Include relevant code examples
- Reference Laravel's official documentation when appropriate
- Consider backward compatibility
- Suggest testing strategies
- Include error handling considerations
- Consider security implications
- Optimize for performance where possible
Would you like me to elaborate on any of these sections or provide specific examples for implementation?