Thank you for your interest in contributing to the PHP Progressive JSON Stream project! π
We welcome contributions from developers of all skill levels. Whether you're fixing a bug, adding a feature, improving documentation, or just asking questions, your contributions help make this project better for everyone.
- Code of Conduct
- Getting Started
- Development Setup
- How to Contribute
- Coding Standards
- Testing Guidelines
- Documentation
- Pull Request Process
- Issue Reporting
- Community
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to el3zahaby@gmail.com.
- PHP 8.0+ (we test on 8.0, 8.1, 8.2, 8.3)
- Composer for dependency management
- Git for version control
- PHPUnit for testing (installed via Composer)
Looking for a good first issue? Check out:
- Issues labeled
good first issue - Issues labeled
help wanted - Documentation improvements
- Test coverage improvements
# Fork the repository on GitHub, then clone your fork
git clone https://github.com/YOUR_USERNAME/progressive-json-php.git
cd progressive-json-php
# Add upstream remote
git remote add upstream https://github.com/egyjs/progressive-json-php.git# Install PHP dependencies
composer install
# Install development dependencies
composer install --dev# Run tests to ensure everything works
composer test
# Run code style checks
composer cs-check
# Run static analysis (if available)
composer analyze# Create a feature branch
git checkout -b feature/your-feature-name
# Or for bug fixes
git checkout -b fix/issue-description-
π Bug Fixes
- Fix existing functionality that doesn't work as expected
- Include test cases that reproduce the bug
- Update documentation if needed
-
β¨ New Features
- Add new functionality that enhances the library
- Discuss major features in an issue first
- Include comprehensive tests and documentation
-
π Documentation
- Improve README, code comments, or examples
- Fix typos or clarify confusing sections
- Add usage examples or tutorials
-
π§ͺ Testing
- Add test cases for uncovered scenarios
- Improve test quality or performance
- Add integration tests
-
π§ Maintenance
- Code refactoring for better performance
- Dependency updates
- CI/CD improvements
We follow PSR-12 coding standards with some additional conventions:
<?php
namespace Egyjs\ProgressiveJson;
/**
* Class documentation should be comprehensive
*
* @package Egyjs\ProgressiveJson
*/
class ExampleClass
{
/**
* Property documentation
*
* @var array<string, mixed>
*/
protected array $data = [];
/**
* Method documentation with clear description
*
* @param string $key The key to set
* @param mixed $value The value to store
* @return self For method chaining
* @throws InvalidArgumentException When key is empty
*/
public function setData(string $key, mixed $value): self
{
if (empty($key)) {
throw new InvalidArgumentException('Key cannot be empty');
}
$this->data[$key] = $value;
return $this;
}
}- Classes:
PascalCase(e.g.,ProgressiveJsonStreamer) - Methods:
camelCase(e.g.,addPlaceholder) - Properties:
camelCase(e.g.,$placeholderMarker) - Constants:
UPPER_SNAKE_CASE(e.g.,DEFAULT_MAX_DEPTH) - Files: Match class names (e.g.,
ProgressiveJsonStreamer.php)
- Type Declarations: Use strict typing (
declare(strict_types=1)) - Return Types: Always specify return types
- Documentation: All public methods must have PHPDoc comments
- Error Handling: Use appropriate exceptions with clear messages
- Fluent Interface: Support method chaining where appropriate
All contributions should include appropriate tests:
<?php
use PHPUnit\Framework\TestCase;
use Egyjs\ProgressiveJson\ProgressiveJsonStreamer;
class FeatureTest extends TestCase
{
public function testFeatureWorksAsExpected(): void
{
// Arrange
$streamer = new ProgressiveJsonStreamer();
$expectedResult = 'expected output';
// Act
$result = $streamer->someMethod();
// Assert
$this->assertEquals($expectedResult, $result);
}
public function testErrorHandling(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Specific error message');
$streamer = new ProgressiveJsonStreamer();
$streamer->invalidOperation();
}
}- Unit Tests: Test individual methods and classes
- Integration Tests: Test component interactions
- Behavioral Tests: Test real-world usage scenarios
- Error Tests: Test exception handling and edge cases
# Run all tests
composer test
# Run tests with coverage
composer test-coverage
# Run specific test file
./vendor/bin/phpunit tests/ProgressiveJsonStreamerTest.php
# Run specific test method
./vendor/bin/phpunit --filter testMethodName- Aim for 90%+ code coverage for new features
- All public methods must be tested
- Critical paths and error conditions must be covered
- Use
@coversannotations to specify what each test covers
- PHPDoc blocks for all public methods and properties
- Clear parameter descriptions with types
- Return value documentation
- Exception documentation with conditions
- Usage examples in complex methods
When adding features:
- Update the feature list
- Add usage examples
- Update installation instructions if needed
- Update the table of contents
Create practical examples that demonstrate:
- Common use cases
- Framework integration
- Error handling
- Performance considerations
-
Update from upstream:
git fetch upstream git rebase upstream/main
-
Run quality checks:
composer test composer cs-check composer analyze # if available
-
Update documentation as needed
-
Write clear commit messages:
git commit -m "feat: add custom placeholder validation - Add validation for placeholder format - Include helpful error messages - Add comprehensive test coverage Closes #123"
When creating a pull request, include:
## Description
Brief description of changes and motivation.
## Type of Change
- [ ] Bug fix (non-breaking change fixing an issue)
- [ ] New feature (non-breaking change adding functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation update
## Testing
- [ ] New tests added for new functionality
- [ ] All existing tests pass
- [ ] Manual testing completed
## Checklist
- [ ] Code follows project style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No new warnings introduced- Automated checks must pass (tests, style, static analysis)
- Code review by maintainers
- Discussion and requested changes if needed
- Approval and merge by maintainers
Use this template for bug reports:
**Bug Description**
Clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Create streamer with '...'
2. Add placeholder '...'
3. Call stream() method
4. See error
**Expected Behavior**
What you expected to happen.
**Actual Behavior**
What actually happened.
**Environment**
- PHP Version: [e.g., 8.2.0]
- Library Version: [e.g., 1.0.0]
- Framework: [e.g., Symfony 6.3, Laravel 10.x, or None]
- OS: [e.g., Ubuntu 22.04, Windows 11, macOS 13]
**Additional Context**
Any other context about the problem.Use this template for feature requests:
**Feature Description**
Clear description of the feature you'd like to see.
**Use Case**
Describe the problem this feature would solve.
**Proposed Solution**
Your ideas for how this could be implemented.
**Alternatives Considered**
Other solutions you've considered.
**Additional Context**
Any other context or screenshots.- GitHub Issues: For bugs and feature requests
- GitHub Discussions: For questions and general discussion
- Email: el3zahaby@gmail.com for sensitive issues
- Be respectful and constructive
- Search existing issues before creating new ones
- Provide context and examples
- Be patient - maintainers are volunteers
- Follow up on your issues and PRs
feature/description- New featuresfix/description- Bug fixesdocs/description- Documentation changesrefactor/description- Code refactoringtest/description- Test improvements
Follow Conventional Commits:
feat: add support for custom error handlers
fix: resolve memory leak in stream processing
docs: update README with new examples
test: add integration tests for Symfony
refactor: optimize placeholder resolution performance- Features are merged to
mainbranch - Semantic versioning is used (
x.y.z) - Releases are tagged and published to Packagist
- Changelog is maintained
Contributors are recognized in:
- CHANGELOG.md for significant contributions
- README.md acknowledgments section
- GitHub releases notes
Don't hesitate to ask questions! We're here to help:
- Create a GitHub Discussion
- Open an issue with the
questionlabel - Email the maintainer: el3zahaby@gmail.com
Thank you for contributing to PHP Progressive JSON Stream! Your efforts help make streaming JSON responses better for everyone. π
Happy coding! β¨