Thank you for your interest in contributing to Apivalk. All contributions are welcome: bug fixes, documentation improvements, new features, and test coverage. This guide covers everything you need to get started.Documentation Index
Fetch the complete documentation index at: https://docs.apivalk.com/llms.txt
Use this file to discover all available pages before exploring further.
Getting Started
1. Fork and Clone
Contributions come from forks — never push directly toapivalk/apivalk.
- Click Fork on github.com/apivalk/apivalk.
- Clone your fork locally:
- Add the upstream remote so you can stay in sync:
2. Create a Branch
Branch offmain. Format: <type>/<issue-id>-<short-description>. If the work has a GitHub issue, the issue ID is required.
3. Set Up the Development Environment
Docker (recommended):composer install with your local setup.
4. Make Your Changes
Write code, add tests, update docs. See the standards section below before submitting.5. Run the Test Suite and Static Analysis
All of the following must pass before opening a PR:phpstan-baseline.neon) covers pre-existing issues — do not add to it.
6. Open a Pull Request
Push your branch to your fork and open a PR againstapivalk/apivalk:main:
- Tests pass (
composer test) - PHPStan passes (
composer phpstan) - Commit messages follow Conventional Commits
- Breaking changes are flagged with
BREAKING CHANGE:in the commit footer - New public APIs have corresponding test coverage
- Docs updated if behaviour changed
Commit Messages
Apivalk uses Conventional Commits.Format
Types
| Type | When to use |
|---|---|
feat | A new feature |
fix | A bug fix |
docs | Documentation only |
test | Adding or fixing tests |
refactor | Code change that is neither a fix nor a feature |
chore | Build process, tooling, dependency updates |
perf | Performance improvement |
Examples
No issue:Issue: #<id>:
Breaking Changes
If your change is not backwards-compatible, addBREAKING CHANGE: in the commit footer and use ! after the type. When an issue is also involved, include both footer lines:
Issues
Reporting a Bug
Open an issue at github.com/apivalk/apivalk/issues and include:- PHP version and Apivalk version (
composer show apivalk/apivalk) - A minimal reproducible example
- What you expected vs. what happened
- Stack trace if applicable
Proposing a Feature
Open an issue before writing code for anything non-trivial. Describe the problem you’re solving, not just the solution. This avoids wasted effort if the direction doesn’t fit the project’s goals.Standards
All contributions must follow these standards. Reviewers will check them.Coding Standards
See the full Coding Standards guide. Key rules:declare(strict_types=1)on every file.- PSR-1 / PSR-12 formatting.
- PHPStan level 6 — no new violations.
- Single Responsibility: one controller per route/method, one request per endpoint, one validator per property type.
- Fail fast: validation happens in middleware, never inside controllers.
- No raw
$_POST/$_GET/$_SERVERin framework code — go through the request abstraction. - Type hints on all method signatures, including return types.
OpenAPI & REST Standards
New endpoints, properties, and response shapes added to examples or how-to guides must comply with the REST API Standards:- REST Design and Naming — resource-oriented URLs, correct HTTP verbs, noun-based naming.
- Versioning and Structure —
/v1/prefix, no breaking changes within a version. - Pagination, Filtering, Sorting — use Apivalk’s built-in strategies; don’t invent custom query param conventions.
- Responses, Errors, Status Codes — use the correct HTTP status code and the built-in typed error responses.
- Localization / i18n —
Accept-Language/Content-LanguageviaLocalizationConfiguration.
Test Coverage
- New features need tests. Follow the existing structure:
Tests/PhpUnit/mirrors the source tree. - Tests must be runnable with
vendor/bin/phpunitand pass on PHP 7.2. - Unit test individual classes; integration tests go through the full
Apivalk::run()lifecycle where relevant.