A comprehensive GitHub Copilot configuration for PHP development, providing expert-level guidance for modern PHP applications with security, performance, and best practices built-in.
This repository contains specialized GitHub Copilot configurations that transform your coding assistant into a Senior PHP Architect and Security Specialist. It includes:
- Expert Chatmode: A specialized PHP Expert persona for planning, coding, and security reviews
- Prompt Library: Ready-to-use prompts for common PHP development tasks
- Standards & Guidelines: Comprehensive PHP coding standards and security practices
- Framework Support: Specialized guidance for Laravel, Symfony, and modern PHP patterns
Before installing, ensure you have:
- GitHub Copilot subscription (required for all functionality)
- VS Code with GitHub Copilot extension installed
- Git (for cloning the repository)
- PHP 8.1+ (for running validation scripts and generated code)
# Check GitHub Copilot is installed and active
code --list-extensions | grep -i copilot
# Verify PHP version (8.1+ required)
php --version
# Check Git is available
git --version
- Clone this repository to your local machine
- Open the folder in VS Code with GitHub Copilot enabled
- The chatmodes, prompts, and instructions will be automatically available
git clone https://github.com/leifrogers/php-copilot.git
cd php-copilot
code .
php scripts/validate.php $(pwd)
If the validation passes, you should see confirmation that all components are properly configured.
Copy the chatmodes/PHP-Expert.chatmode.md
file to your VS Code chatmodes directory:
# For VS Code
cp chatmodes/PHP-Expert.chatmode.md ~/.vscode/chatmodes/
In GitHub Copilot Chat, activate the PHP Expert mode and use these commands:
/plan
- Break down feature requests into detailed implementation plans/review
- Perform comprehensive security and performance code reviews/generate
- Create PHP code following best practices/test
- Generate PHPUnit tests for your classes
Use the specialized prompts in the prompts/
directory for specific tasks:
create-phpunit-test.prompt.md
- Generate comprehensive test suiteslaravel-crud-stub.prompt.md
- Create complete Laravel CRUD resourcesrefactor-to-class.prompt.md
- Modernize legacy procedural codesymfony-service-class.prompt.md
- Generate Symfony service classes
@PHP-Expert /plan
Create a user authentication system with JWT tokens, rate limiting, and password reset functionality.
@PHP-Expert /review
[Select your PHP code and the expert will provide security, performance, and architectural feedback]
Use the create-phpunit-test prompt with #file pointing to your PHP class to generate comprehensive PHPUnit tests.
- SQL injection prevention with prepared statements
- XSS protection and input validation
- CSRF token implementation
- Secure file handling and authentication patterns
- Modern PHP 8.x features (enums, readonly properties, union types)
- Efficient database query patterns
- Caching strategies and memory optimization
- N+1 query prevention
- PSR-1, PSR-4, PSR-12 compliance
- SOLID principles enforcement
- Comprehensive PHPDoc documentation
- Test-driven development practices
- Laravel best practices (Eloquent, Form Requests, Middleware)
- Symfony patterns (DI Container, Services, Doctrine)
- Modern PHP patterns and architecture
- GitHub Copilot subscription (required)
- VS Code with GitHub Copilot extension
- PHP 8.1+ development environment (for generated code)
The PHP Expert is designed to be your senior colleague in the codebase. It will:
- Explain architectural decisions and best practices
- Provide security-focused solutions
- Generate production-ready code with proper error handling
- Create comprehensive tests for your classes
php-copilot/
βββ chatmodes/
β βββ API-Expert.chatmode.md # API development specialist
β βββ Laravel-Expert.chatmode.md # Laravel framework expert
β βββ PHP-Expert.chatmode.md # Main PHP expert persona
β βββ Symfony-Expert.chatmode.md # Symfony framework expert
βββ instructions/
β βββ api-standards.instructions.md # API development standards
β βββ laravel-standards.instructions.md # Laravel coding standards
β βββ php-standards.instructions.md # Comprehensive PHP standards
β βββ symfony-standards.instructions.md # Symfony coding standards
βββ prompts/
β βββ code-review.prompt.md # Code review and analysis
β βββ create-api-endpoint.prompt.md # API endpoint generation
β βββ create-migration.prompt.md # Database migration creation
β βββ create-phpunit-test.prompt.md # Test generation
β βββ laravel-crud-stub.prompt.md # Laravel CRUD scaffolding
β βββ performance-analysis.prompt.md # Performance optimization
β βββ refactor-legacy.prompt.md # Legacy code modernization
β βββ refactor-to-class.prompt.md # OOP refactoring
β βββ security-review.prompt.md # Security analysis
β βββ symfony-service-class.prompt.md # Symfony service creation
βββ scripts/
β βββ validate.php # Validation script
βββ LICENSE # MIT License
βββ README.md # This file
- Planning: Detailed feature breakdown with file lists, database changes, and test requirements
- Review: Security vulnerability detection, performance analysis, and standards compliance
- Architecture: SOLID principles guidance and modern PHP patterns
- Testing: PHPUnit test generation and TDD practices
- PHP 8.1+ compatibility requirements
- Strict typing enforcement (
declare(strict_types=1)
) - Modern language features (constructor promotion, match expressions, enums)
- Security-first coding practices
- Performance optimization guidelines
Each prompt is designed for specific development scenarios:
- Testing: Generate complete test suites with mocking and edge cases
- CRUD Operations: Full Laravel resource scaffolding
- Legacy Modernization: Convert procedural code to OOP with modern PHP
- Service Architecture: Symfony-style service creation with DI
Each prompt is designed for specific development scenarios:
- Testing: Generate complete test suites with mocking and edge cases
- CRUD Operations: Full Laravel resource scaffolding
- Legacy Modernization: Convert procedural code to OOP with modern PHP
- Service Architecture: Symfony-style service creation with DI
- GitHub Copilot subscription
- VS Code with GitHub Copilot extension
- PHP 8.1+ development environment (for generated code)
The PHP Expert is designed to be your senior colleague in the codebase. It will:
- Explain architectural decisions and best practices
- Provide security-focused solutions
- Generate production-ready code with proper error handling
- Create comprehensive tests for your classes
- Help modernize legacy PHP applications
- Ensure you have an active GitHub Copilot subscription
- Verify the extension is enabled in VS Code
- Try reloading VS Code window (
Cmd+R
on macOS)
- Check that chatmode files are in the correct directory
- Restart VS Code after copying files
- Verify file permissions are correct
# Ensure PHP 8.1+ is installed
php --version
# Check file permissions
ls -la scripts/validate.php
# Run with verbose output
php scripts/validate.php $(pwd) --verbose
- Create an issue on GitHub for bugs or feature requests
- Check existing issues for similar problems
- Provide system information and error messages when reporting issues
A: Yes, this project requires an active GitHub Copilot subscription to function.
A: Absolutely! All files are designed to be customizable for your team's needs.
A: PHP 8.1 and higher. The generated code uses modern PHP features.
A: Currently optimized for VS Code, but prompts and instructions can be adapted for other editors.
We welcome contributions that enhance the PHP development experience! Here's how to contribute:
- Fork the repository and create a feature branch
- Follow PHP standards outlined in
instructions/php-standards.instructions.md
- Test your changes using the validation script
- Update documentation if adding new features
- Submit a pull request with a clear description
- Additional framework-specific chatmodes
- New prompts for common development tasks
- Security enhancements and best practices
- Performance optimization patterns
- Documentation improvements
- Follow PSR-12 coding standards
- Include comprehensive documentation
- Add tests for new functionality
- Maintain backward compatibility