|
| 1 | +--- |
| 2 | +description: |
| 3 | +globs: |
| 4 | +alwaysApply: true |
| 5 | +--- |
| 6 | +# Sentry PHP SDK Development Rules |
| 7 | + |
| 8 | +## Project Overview |
| 9 | +The Sentry PHP SDK is an official error tracking and monitoring library for PHP applications. It provides error reporting, performance monitoring, and crash reporting capabilities. |
| 10 | + |
| 11 | +## Core Requirements |
| 12 | + |
| 13 | +### PHP Version Compatibility |
| 14 | +- All code must support PHP 7.2 and up (including PHP 8.x) |
| 15 | +- Use appropriate type hints and features compatible with the minimum PHP version |
| 16 | +- Test against multiple PHP versions in CI |
| 17 | + |
| 18 | +### Breaking Changes Policy |
| 19 | +- No breaking changes to any public methods are allowed in minor/patch releases |
| 20 | +- Existing methods in interfaces cannot be altered without major version bump |
| 21 | +- Follow semantic versioning strictly as defined in [CONTRIBUTING.md](mdc:CONTRIBUTING.md) |
| 22 | + |
| 23 | +## Code Quality Standards |
| 24 | + |
| 25 | +### Code Style and Linting |
| 26 | +- All code must adhere to the project's code style |
| 27 | +- Run `composer cs-check` to check for linting errors |
| 28 | +- Use `composer cs-fix` to automatically fix linting issues |
| 29 | +- Configuration is in [.php-cs-fixer.dist.php](mdc:.php-cs-fixer.dist.php) |
| 30 | + |
| 31 | +### Static Analysis |
| 32 | +- Code must pass PHPStan analysis (`composer phpstan`) |
| 33 | +- Code must pass Psalm analysis (`composer psalm`) |
| 34 | +- Baseline files exist for legacy issues: [phpstan-baseline.neon](mdc:phpstan-baseline.neon) and [psalm-baseline.xml](mdc:psalm-baseline.xml) |
| 35 | + |
| 36 | +### Testing Requirements |
| 37 | +- All new features require comprehensive tests |
| 38 | +- Tests are located in the [tests/](mdc:tests) directory |
| 39 | +- Run tests with `composer tests` or `vendor/bin/phpunit` |
| 40 | +- Test structure mirrors the src/ directory structure |
| 41 | +- Use PHPUnit for unit testing |
| 42 | + |
| 43 | +## Project Structure |
| 44 | + |
| 45 | +### Main Source Code |
| 46 | +- Core SDK code is in [src/](mdc:src) directory |
| 47 | +- Entry point functions are in [src/functions.php](mdc:src/functions.php) |
| 48 | +- Main client class is [src/Client.php](mdc:src/Client.php) |
| 49 | +- Configuration handled by [src/Options.php](mdc:src/Options.php) |
| 50 | + |
| 51 | +### Key Components |
| 52 | +- **Events**: [src/Event.php](mdc:src/Event.php) - Core event structure |
| 53 | +- **Error Handling**: [src/ErrorHandler.php](mdc:src/ErrorHandler.php) - Error capture |
| 54 | +- **Integrations**: [src/Integration/](mdc:src/Integration) - Framework integrations |
| 55 | +- **Transport**: [src/Transport/](mdc:src/Transport) - Data transmission |
| 56 | +- **Serialization**: [src/Serializer/](mdc:src/Serializer) - Data serialization |
| 57 | +- **Tracing**: [src/Tracing/](mdc:src/Tracing) - Performance monitoring |
| 58 | +- **Profiling**: [src/Profiling/](mdc:src/Profiling) - Performance profiling |
| 59 | + |
| 60 | +### Dependencies |
| 61 | +- Core dependencies defined in [composer.json](mdc:composer.json) |
| 62 | +- PSR-7 HTTP messages via guzzlehttp/psr7 |
| 63 | +- Symfony OptionsResolver for configuration |
| 64 | +- PSR-3 logging interface support |
| 65 | + |
| 66 | +## Development Workflow |
| 67 | + |
| 68 | +### Code Formatting |
| 69 | +- Always add import statements for all classes and functions used |
| 70 | +- Use proper PHP namespacing (`Sentry\` namespace) |
| 71 | +- Follow PSR-4 autoloading standards |
| 72 | + |
| 73 | +### Commit Messages |
| 74 | +- Follow the commit message format: https://develop.sentry.dev/commit-messages/#commit-message-format |
| 75 | +- Use conventional commits for automatic changelog generation |
| 76 | + |
| 77 | +### Pull Request Guidelines |
| 78 | +- Read [CONTRIBUTING.md](mdc:CONTRIBUTING.md) before submitting PRs |
| 79 | +- PRs use LOGAF scale for feedback (Low, Medium, High priority comments) |
| 80 | +- Ensure all CI checks pass (tests, linting, static analysis) |
| 81 | +- Add appropriate tests for new functionality |
| 82 | + |
| 83 | +## Common Patterns |
| 84 | + |
| 85 | +### Error Handling |
| 86 | +- Use proper exception handling and logging |
| 87 | +- Capture exceptions with appropriate context |
| 88 | +- Follow Sentry's error reporting best practices |
| 89 | + |
| 90 | +### Configuration |
| 91 | +- Use [src/Options.php](mdc:src/Options.php) for configuration management |
| 92 | +- Support environment-based configuration |
| 93 | +- Provide sensible defaults |
| 94 | + |
| 95 | +### Integration Development |
| 96 | +- New integrations go in [src/Integration/](mdc:src/Integration) |
| 97 | +- Follow existing integration patterns |
| 98 | +- Provide proper setup and teardown methods |
| 99 | +- Document integration usage |
| 100 | + |
| 101 | +### Testing Patterns |
| 102 | +- Test files mirror source structure in [tests/](mdc:tests) |
| 103 | +- Use descriptive test method names |
| 104 | +- Include both positive and negative test cases |
| 105 | +- Mock external dependencies appropriately |
| 106 | + |
| 107 | +## Documentation |
| 108 | +- Update [CHANGELOG.md](mdc:CHANGELOG.md) for user-facing changes |
| 109 | +- Follow upgrade guides pattern for breaking changes |
| 110 | +- Maintain compatibility with official Sentry documentation |
| 111 | + |
| 112 | +## Release Process |
| 113 | +- Releases are managed through GitHub Actions and Craft |
| 114 | +- Follow the release process outlined in [CONTRIBUTING.md](mdc:CONTRIBUTING.md) |
| 115 | +- Two-person approval process for releases |
| 116 | +- Automatic changelog generation from conventional commits |
0 commit comments