Contributing
Contributions to php-pdftk are highly encouraged! Whether you are fixing bugs, improving documentation, or ensuring compatibility with newer PHP versions, your help is welcome.
Development Environment Setup
To run the tests and static analysis tools locally, you will need:
- PHP 8.1 or higher.
- Composer installed globally.
- The
pdftkbinary installed on your local system (the test suite executes real PDF manipulations).
# 1. Clone the repository
git clone https://github.com/mikehaertl/php-pdftk.git
cd php-pdftk
# 2. Install dependencies (including dev tools)
composer install
Testing
The library uses PHPUnit for its testing framework. Before submitting a pull request, ensure that all existing tests pass.
To run the unit test suite:
composer run test:unit
If you have Xdebug configured for coverage, you can generate a test coverage report:
composer run test:coverage
Static Analysis
We utilize Psalm to enforce strict type checking and catch potential runtime errors statically.
To run Psalm across the codebase:
composer run psalm
If you introduce code that intentionally violates a strict Psalm rule for a valid architectural reason, please discuss it in your Pull Request.
Coding Standards
The project strictly adheres to coding standards enforced by php-cs-fixer. Clean, consistent code makes the project easier to maintain.
To verify your code against the style guide (dry-run):
composer run cs:check
To automatically fix formatting issues in your files:
composer run cs:fix
For a fast syntax check (linting) across all PHP files to catch basic parse errors:
composer run lint
Submitting a Pull Request
- Fork the repository and create a feature branch (
git checkout -b feature/my-new-feature). - Write clear, descriptive commit messages.
- Include tests for any new features or bug fixes.
- Run
composer run test:unit,composer run psalm, andcomposer run cs:fixto ensure your build will pass CI. - Open a Pull Request against the
masterbranch, explaining the problem you are solving and your approach.