|
| 1 | +# Contributing to Knocker for Laravel |
| 2 | + |
| 3 | +Thank you for considering contributing to Knocker for Laravel! This document outlines the guidelines and processes for contributing to this project. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Code of Conduct](#code-of-conduct) |
| 8 | +- [Getting Started](#getting-started) |
| 9 | +- [Development Setup](#development-setup) |
| 10 | +- [Coding Standards](#coding-standards) |
| 11 | +- [Testing](#testing) |
| 12 | +- [Pull Request Process](#pull-request-process) |
| 13 | +- [Issue Reporting](#issue-reporting) |
| 14 | +- [Security Vulnerabilities](#security-vulnerabilities) |
| 15 | + |
| 16 | +## Code of Conduct |
| 17 | + |
| 18 | +This project adheres to a code of conduct that promotes a welcoming and inclusive environment. By participating, you are expected to uphold this standard. Please be respectful and professional in all interactions. |
| 19 | + |
| 20 | +## Getting Started |
| 21 | + |
| 22 | +### Prerequisites |
| 23 | + |
| 24 | +Before contributing, ensure you have the following installed: |
| 25 | + |
| 26 | +- **PHP 8.3 or higher** |
| 27 | +- **Composer** (latest version) |
| 28 | +- **Git** |
| 29 | +- A **Laravel application** for testing (Laravel 12.0+) |
| 30 | + |
| 31 | +### Fork and Clone |
| 32 | + |
| 33 | +1. Fork the repository on GitHub |
| 34 | +2. Clone your fork locally: |
| 35 | + |
| 36 | + ```bash |
| 37 | + git clone https://github.com/kapersoft/knocker-for-laravel.git |
| 38 | + cd knocker-for-laravel |
| 39 | + ``` |
| 40 | + |
| 41 | +## Development Setup |
| 42 | + |
| 43 | +### Install Dependencies |
| 44 | + |
| 45 | +```bash |
| 46 | +composer install |
| 47 | +``` |
| 48 | + |
| 49 | +### Development Tools |
| 50 | + |
| 51 | +This project uses several development tools that are automatically configured: |
| 52 | + |
| 53 | +- **Pest** - Testing framework |
| 54 | +- **PHPStan** - Static analysis |
| 55 | +- **Laravel Pint** - Code formatting |
| 56 | +- **Rector** - Code refactoring and modernization |
| 57 | + |
| 58 | +### Available Commands |
| 59 | + |
| 60 | +```bash |
| 61 | +# Run tests |
| 62 | +composer test |
| 63 | + |
| 64 | +# Run tests with coverage |
| 65 | +composer test-coverage |
| 66 | + |
| 67 | +# Run static analysis |
| 68 | +composer analyse |
| 69 | + |
| 70 | +# Format code |
| 71 | +composer format |
| 72 | + |
| 73 | +# Prepare package for development |
| 74 | +composer prepare |
| 75 | +``` |
| 76 | + |
| 77 | +## Coding Standards |
| 78 | + |
| 79 | +### PHP Standards |
| 80 | + |
| 81 | +- Follow **PSR-12** coding standards |
| 82 | +- Use **strict types** declarations in all PHP files |
| 83 | +- Write **type hints** for all method parameters and return types |
| 84 | +- Use **meaningful variable and method names** |
| 85 | + |
| 86 | +### Code Formatting |
| 87 | + |
| 88 | +Code formatting is handled automatically by Laravel Pint. Run the formatter before committing: |
| 89 | + |
| 90 | +```bash |
| 91 | +composer format |
| 92 | +``` |
| 93 | + |
| 94 | +### Static Analysis |
| 95 | + |
| 96 | +All code must pass PHPStan analysis at the highest level. Run static analysis with: |
| 97 | + |
| 98 | +```bash |
| 99 | +composer analyse |
| 100 | +``` |
| 101 | + |
| 102 | +### Architecture Guidelines |
| 103 | + |
| 104 | +- Follow **SOLID principles** |
| 105 | +- Use **dependency injection** where appropriate |
| 106 | +- Keep classes **focused and single-purpose** |
| 107 | +- Write **self-documenting code** with clear method names |
| 108 | +- Add **PHPDoc blocks** for complex methods |
| 109 | + |
| 110 | +## Testing |
| 111 | + |
| 112 | +### Writing Tests |
| 113 | + |
| 114 | +- All new features must include comprehensive tests |
| 115 | +- Use **Pest** testing framework |
| 116 | +- Follow the **AAA pattern** (Arrange, Act, Assert) |
| 117 | +- Write both **unit tests** and **integration tests** where appropriate |
| 118 | + |
| 119 | +### Test Structure |
| 120 | + |
| 121 | +```php |
| 122 | +<?php |
| 123 | + |
| 124 | +use Kapersoft\Knocker\YourClass; |
| 125 | + |
| 126 | +it('can perform the expected action', function () { |
| 127 | + // Arrange |
| 128 | + $instance = new YourClass(); |
| 129 | + |
| 130 | + // Act |
| 131 | + $result = $instance->performAction(); |
| 132 | + |
| 133 | + // Assert |
| 134 | + expect($result)->toBe('expected_value'); |
| 135 | +}); |
| 136 | +``` |
| 137 | + |
| 138 | +### Running Tests |
| 139 | + |
| 140 | +```bash |
| 141 | +# Run all tests |
| 142 | +composer test |
| 143 | + |
| 144 | +# Run tests with coverage report |
| 145 | +composer test-coverage |
| 146 | + |
| 147 | +# Run specific test file |
| 148 | +vendor/bin/pest tests/YourTestFile.php |
| 149 | +``` |
| 150 | + |
| 151 | +### Test Coverage |
| 152 | + |
| 153 | +- Aim for **high test coverage** (90%+) |
| 154 | +- All public methods should be tested |
| 155 | +- Test both **happy paths** and **error conditions** |
| 156 | + |
| 157 | +## Pull Request Process |
| 158 | + |
| 159 | +### Before Submitting |
| 160 | + |
| 161 | +1. **Create a feature branch** from `main`: |
| 162 | + |
| 163 | + ```bash |
| 164 | + git checkout -b feature/your-feature-name |
| 165 | + ``` |
| 166 | + |
| 167 | +2. **Make your changes** following the coding standards |
| 168 | + |
| 169 | +3. **Run the full test suite**: |
| 170 | + |
| 171 | + ```bash |
| 172 | + composer test |
| 173 | + composer analyse |
| 174 | + composer format |
| 175 | + ``` |
| 176 | + |
| 177 | +4. **Update documentation** if necessary |
| 178 | + |
| 179 | +5. **Add or update tests** for your changes |
| 180 | + |
| 181 | +### Pull Request Guidelines |
| 182 | + |
| 183 | +1. **Clear title and description** - Explain what your PR does and why |
| 184 | +2. **Reference related issues** - Use "Fixes #123" or "Closes #123" |
| 185 | +3. **Keep PRs focused** - One feature or fix per PR |
| 186 | +4. **Update CHANGELOG.md** - Add your changes under "Unreleased" |
| 187 | +5. **Ensure CI passes** - All GitHub Actions must be green |
| 188 | + |
| 189 | +### PR Template |
| 190 | + |
| 191 | +```markdown |
| 192 | +## Description |
| 193 | +Brief description of the changes made. |
| 194 | + |
| 195 | +## Type of Change |
| 196 | +- [ ] Bug fix |
| 197 | +- [ ] New feature |
| 198 | +- [ ] Documentation update |
| 199 | + |
| 200 | +## Testing |
| 201 | +- [ ] Tests pass locally |
| 202 | +- [ ] New tests added for new functionality |
| 203 | +- [ ] Manual testing completed |
| 204 | + |
| 205 | +## Checklist |
| 206 | +- [ ] Code follows project coding standards |
| 207 | +- [ ] Self-review completed |
| 208 | +- [ ] Documentation updated |
| 209 | +- [ ] CHANGELOG.md updated |
| 210 | +``` |
| 211 | + |
| 212 | +## Issue Reporting |
| 213 | + |
| 214 | +### Bug Reports |
| 215 | + |
| 216 | +When reporting bugs, please include: |
| 217 | + |
| 218 | +- **Laravel version** |
| 219 | +- **PHP version** |
| 220 | +- **Package version** |
| 221 | +- **Steps to reproduce** |
| 222 | +- **Expected behavior** |
| 223 | +- **Actual behavior** |
| 224 | +- **Error messages** (if any) |
| 225 | +- **Code samples** (if applicable) |
| 226 | + |
| 227 | +### Feature Requests |
| 228 | + |
| 229 | +For feature requests, please provide: |
| 230 | + |
| 231 | +- **Clear description** of the proposed feature |
| 232 | +- **Use case** - Why is this feature needed? |
| 233 | +- **Proposed implementation** (if you have ideas) |
| 234 | +- **Alternatives considered** |
| 235 | + |
| 236 | +## Security Vulnerabilities |
| 237 | + |
| 238 | +Please review [our security policy](SECURITY.MD) for information on reporting security vulnerabilities. |
| 239 | + |
| 240 | +**Do not report security vulnerabilities through public GitHub issues.** |
| 241 | + |
| 242 | +## Development Workflow |
| 243 | + |
| 244 | +### Branching Strategy |
| 245 | + |
| 246 | +- `main` - Production-ready code |
| 247 | +- `feature/*` - New features |
| 248 | +- `bugfix/*` - Bug fixes |
| 249 | +- `hotfix/*` - Critical fixes |
| 250 | + |
| 251 | +### Commit Messages |
| 252 | + |
| 253 | +Use clear, descriptive commit messages: |
| 254 | + |
| 255 | +```txt |
| 256 | +feat: add support for custom cron expressions |
| 257 | +fix: resolve timezone handling in scheduler tasks |
| 258 | +docs: update installation instructions |
| 259 | +test: add integration tests for command registration |
| 260 | +``` |
| 261 | + |
| 262 | +### Release Process |
| 263 | + |
| 264 | +Releases are handled by maintainers and follow semantic versioning: |
| 265 | + |
| 266 | +- **MAJOR** - Breaking changes |
| 267 | +- **MINOR** - New features (backward compatible) |
| 268 | +- **PATCH** - Bug fixes (backward compatible) |
| 269 | + |
| 270 | +## Getting Help |
| 271 | + |
| 272 | +- **Documentation** - Check the README.md first |
| 273 | +- **Issues** - Search existing issues before creating new ones |
| 274 | +- **Discussions** - Use GitHub Discussions for questions |
| 275 | +- **Email ** - Contact [[email protected]](mailto:[email protected]) for private matters |
| 276 | + |
| 277 | +## Recognition |
| 278 | + |
| 279 | +Contributors will be recognized in: |
| 280 | + |
| 281 | +- The project's README.md |
| 282 | +- Release notes for significant contributions |
| 283 | +- GitHub's contributor graph |
| 284 | + |
| 285 | +Thank you for contributing to Knocker for Laravel! 🚀 |
0 commit comments