|
| 1 | +# Contributing to lean-http |
| 2 | + |
| 3 | +Thank you for your interest in contributing to lean-http! This document provides guidelines and instructions for contributing to the project. |
| 4 | + |
| 5 | +## Getting Started |
| 6 | + |
| 7 | +1. **Fork the repository** on GitHub |
| 8 | +2. **Clone your fork** locally: |
| 9 | + ```bash |
| 10 | + git clone https://github.com/your-username/lean-http.git |
| 11 | + cd lean-http |
| 12 | + ``` |
| 13 | +3. **Install dependencies**: |
| 14 | + ```bash |
| 15 | + composer install |
| 16 | + ``` |
| 17 | +4. **Setup git hooks** (optional but recommended): |
| 18 | + ```bash |
| 19 | + chmod +x scripts/setup-git-hooks.sh |
| 20 | + ./scripts/setup-git-hooks.sh |
| 21 | + ``` |
| 22 | + |
| 23 | + This will enable a pre-commit hook that automatically runs code style checks, static analysis, and tests before allowing commits. This helps catch issues early and keeps the codebase clean. |
| 24 | + |
| 25 | +## Development Workflow |
| 26 | + |
| 27 | +### Making Changes |
| 28 | + |
| 29 | +1. Create a new branch for your changes: |
| 30 | + ```bash |
| 31 | + git checkout -b feature/your-feature-name |
| 32 | + ``` |
| 33 | + or |
| 34 | + ```bash |
| 35 | + git checkout -b fix/your-bug-fix |
| 36 | + ``` |
| 37 | + |
| 38 | +2. Make your changes following the coding standards (see below) |
| 39 | + |
| 40 | +3. Run the quality checks before committing: |
| 41 | + ```bash |
| 42 | + # Run tests |
| 43 | + composer test |
| 44 | + |
| 45 | + # Check code style |
| 46 | + composer cs-check |
| 47 | + |
| 48 | + # Run static analysis |
| 49 | + composer phpstan |
| 50 | + ``` |
| 51 | + |
| 52 | +4. Fix any issues found by the tools: |
| 53 | + ```bash |
| 54 | + # Auto-fix code style issues |
| 55 | + composer cs-fix |
| 56 | + ``` |
| 57 | + |
| 58 | +5. Commit your changes with a clear, descriptive commit message |
| 59 | + |
| 60 | +6. Push to your fork and create a pull request |
| 61 | + |
| 62 | +## Coding Standards |
| 63 | + |
| 64 | +### Code Style |
| 65 | + |
| 66 | +This project follows **PSR-12** coding standards. We use PHP CS Fixer to enforce code style consistency. |
| 67 | + |
| 68 | +- Run `composer cs-check` to check for style issues |
| 69 | +- Run `composer cs-fix` to automatically fix style issues |
| 70 | + |
| 71 | +### Static Analysis |
| 72 | + |
| 73 | +We use PHPStan for static analysis to catch potential bugs and type issues. |
| 74 | + |
| 75 | +- Run `composer phpstan` to check for issues |
| 76 | +- PHPStan is configured at level 8 (maximum strictness) |
| 77 | + |
| 78 | +### Testing |
| 79 | + |
| 80 | +- All new features should include tests |
| 81 | +- All bug fixes should include tests that demonstrate the fix |
| 82 | +- Run `composer test` to execute the test suite |
| 83 | +- Ensure all tests pass before submitting a pull request |
| 84 | + |
| 85 | +### Documentation |
| 86 | + |
| 87 | +- Update the README.md if you add new features or change existing behavior |
| 88 | +- Add PHPDoc comments for new classes, methods, and properties |
| 89 | +- Update CHANGELOG.md with your changes (see below) |
| 90 | + |
| 91 | +## Pull Request Process |
| 92 | + |
| 93 | +1. **Fork and PR:** Fork the repository and create a pull request for any changes |
| 94 | +2. **Include tests:** All changes should include relevant tests |
| 95 | +3. **Update documentation:** Update README.md and other documentation as needed |
| 96 | +4. **Update CHANGELOG:** Add an entry to CHANGELOG.md describing your changes |
| 97 | +5. **Ensure quality checks pass:** All tests, code style checks, and static analysis must pass |
| 98 | + |
| 99 | +### Pull Request Checklist |
| 100 | + |
| 101 | +- [ ] Code follows PSR-12 coding standards |
| 102 | +- [ ] All tests pass (`composer test`) |
| 103 | +- [ ] Code style is correct (`composer cs-check`) |
| 104 | +- [ ] Static analysis passes (`composer phpstan`) |
| 105 | +- [ ] Documentation is updated (README.md, PHPDoc) |
| 106 | +- [ ] CHANGELOG.md is updated |
| 107 | +- [ ] Commit messages are clear and descriptive |
| 108 | + |
| 109 | +## Issue Tracking |
| 110 | + |
| 111 | +Use GitHub issues to: |
| 112 | +- Report bugs |
| 113 | +- Suggest new features |
| 114 | +- Ask questions |
| 115 | +- Discuss improvements |
| 116 | + |
| 117 | +When reporting bugs, please include: |
| 118 | +- PHP version |
| 119 | +- Steps to reproduce |
| 120 | +- Expected behavior |
| 121 | +- Actual behavior |
| 122 | +- Any relevant error messages or stack traces |
| 123 | + |
| 124 | +## Using AI Tools |
| 125 | + |
| 126 | +Using AI tools like GitHub Copilot, ChatGPT, or similar tools is **encouraged** to: |
| 127 | +- Find issues faster |
| 128 | +- Ensure specifications are followed |
| 129 | +- Improve code quality |
| 130 | +- Generate test cases |
| 131 | + |
| 132 | +However, **always apply critical thinking** and carefully review AI-generated suggestions. AI tools are assistants, not replacements for human judgment. |
| 133 | + |
| 134 | +## Code Review |
| 135 | + |
| 136 | +All pull requests will be reviewed. Reviewers may: |
| 137 | +- Request changes |
| 138 | +- Ask questions |
| 139 | +- Suggest improvements |
| 140 | +- Approve the changes |
| 141 | + |
| 142 | +Please be patient and responsive to feedback. The goal is to maintain high code quality and consistency. |
| 143 | + |
| 144 | +## Questions? |
| 145 | + |
| 146 | +If you have questions about contributing, feel free to: |
| 147 | +- Open an issue on GitHub |
| 148 | +- Check existing issues and discussions |
| 149 | +- Review the README.md for project information |
| 150 | + |
| 151 | +Thank you for contributing to lean-http! 🎉 |
0 commit comments