Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to this project.
This project follows a code of professional conduct. Please be respectful and constructive in all interactions.
- PHP >= 8.2
- Composer >= 2.7
- Git
- Node.js >= 20 (for contract synchronization scripts)
-
Fork and clone the repository:
git clone https://github.com/YOUR-USERNAME/request-network-api-client-php.git cd request-network-api-client-php -
Install dependencies:
composer install npm install
-
Verify your setup:
composer test composer stan composer cs
.
├── src/ # Source code
│ ├── Core/ # HTTP client, config, exceptions, retry logic
│ ├── Domains/ # API domain facades (requests, payments, etc.)
│ ├── Webhooks/ # Webhook verification and parsing
│ ├── Validation/ # Schema validation
│ └── Logging/ # Logging and redaction
├── tests/ # PHPUnit tests
│ └── Unit/ # Unit tests
├── examples/ # Usage examples
├── docs/ # Documentation
└── specs/ # OpenAPI & webhook specifications (synced)
-
Create a feature branch:
git checkout -b feature/my-new-feature # or git checkout -b fix/issue-description -
Write your code:
- Follow PSR-12 coding style
- Add
declare(strict_types=1);to all PHP files - Include PHPDoc for all public methods
- Write tests for new functionality
-
Run quality checks:
# Run tests composer test # Static analysis composer stan # Code style composer cs # Fix code style issues composer cs:fix # Check code complexity/quality composer md
-
Commit your changes:
git add . git commit -m "feat: add new feature description"
Follow conventional commit format:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changestest:- Test additions/changesrefactor:- Code refactoringchore:- Maintenance tasks
-
Push and create a pull request:
git push origin feature/my-new-feature
- PSR-12: Follow PSR-12 coding style
- Strict types: Always use
declare(strict_types=1); - Type hints: Use type hints for all parameters and return types
- PHPDoc: Document all public APIs with PHPDoc blocks
- Readonly: Use
readonlyfor immutable properties where appropriate
<?php
declare(strict_types=1);
namespace RequestSuite\RequestPhpClient\Example;
/**
* Example class demonstrating coding standards.
*/
final class ExampleClass
{
/**
* Process a payment request.
*
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
public function processPayment(array $data): array
{
// Implementation
return [];
}
}- Write tests for all new features
- Maintain or improve code coverage (target: >= 80%)
- Use the
FakeHttpAdapterfor testing API interactions - Name test methods descriptively:
test_it_creates_camelpay_with_valid_data()
<?php
declare(strict_types=1);
namespace RequestSuite\RequestPhpClient\Tests\Unit;
use PHPUnit\Framework\TestCase;
use RequestSuite\RequestPhpClient\RequestClient;
use RequestSuite\RequestPhpClient\Testing\FakeHttpAdapter;
final class ExampleTest extends TestCase
{
public function test_it_creates_client_successfully(): void
{
$fake = new FakeHttpAdapter([
FakeHttpAdapter::jsonResponse(['requestId' => 'req_123']),
]);
$client = RequestClient::create([
'apiKey' => 'rk_test',
'httpAdapter' => $fake,
]);
$result = $client->requests()->create(['amount' => '100']);
$this->assertEquals('req_123', $result['requestId']);
}
}- README.md: Update for new features or changed APIs
- docs/: Add detailed guides for significant features
- CHANGELOG.md: Document all notable changes
- Examples: Add examples for new functionality
- Be concise and clear
- Include code examples
- Link to related documentation
- Keep it up-to-date with code changes
Before submitting your PR, ensure:
- Tests pass (
composer test) - PHPStan analysis passes (
composer stan) - Code style is correct (
composer cs) - New functionality has tests
- Documentation is updated
- CHANGELOG.md is updated (for notable changes)
- Commit messages follow conventional commit format
- PR description explains the changes
- Keep PRs focused: One feature/fix per PR
- Write clear descriptions: Explain what and why
- Link related issues: Reference issues in PR description
- Respond to feedback: Address review comments promptly
- Keep it current: Rebase on main if needed
- Search existing issues to avoid duplicates
- Ensure you're using the latest version
- Collect relevant information (PHP version, package version, error messages)
Use the provided issue templates for:
- Bug reports: Include reproduction steps
- Feature requests: Explain use case and proposed solution
Do not create public issues for security vulnerabilities. See SECURITY.md for reporting instructions.
The client uses shared OpenAPI and webhook specifications:
# Sync specifications from contracts package
composer update:spec
# Verify parity
composer parity:openapi
composer parity:webhooks(For maintainers)
- Update version in
composer.json - Update
CHANGELOG.md - Commit:
git commit -m "chore: bump to v0.x.y" - Tag:
git tag v0.x.y - Push:
git push && git push --tags - Packagist will automatically detect the release
- Documentation: Check
docs/directory - Examples: See
examples/directory - Discussions: Use GitHub Discussions for questions
- Issues: Report bugs or request features via GitHub Issues
By contributing, you agree that your contributions will be licensed under the MIT License.
Your contributions help make this library better for everyone. We appreciate your time and effort!