smarterp-dev / pdf-template
A Laravel package for creating PDF documents using mPDF with Khmer language support
Requires
- php: ^7.4|^8.0
- illuminate/http: ^8.0|^9.0|^10.0
- illuminate/support: ^8.83
- mpdf/mpdf: ^8.0
Requires (Dev)
- mockery/mockery: ^1.4
- orchestra/testbench: ^6.47
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2025-07-29 11:11:55 UTC
README
PDF Template Package
A Laravel package for generating PDF documents using mPDF with Khmer font support and custom templates.
Project Setup
Prerequisites
Before running tests or using the package, ensure you have:
-
Installed all dependencies:
composer install
-
Created the required temporary directory for mPDF:
mkdir -p temp/pdf
Running Tests
You can run the test suite using any of these methods:
-
Using Composer script (recommended):
composer test
-
Running PHPUnit directly:
vendor/bin/phpunit
-
Running specific test suite:
vendor/bin/phpunit --testsuite=Unit
-
Running a specific test file:
vendor/bin/phpunit tests/Unit/TemplateTest.php
-
Running a specific test method:
vendor/bin/phpunit --filter=it_can_get_config_with_default_values
Test Coverage Report
To generate an HTML test coverage report, run:
composer test-coverage
This will create HTML reports in the coverage
directory.
Continuous Integration
GitHub Actions workflow in .github/workflows/run-tests.yml
automatically runs tests across multiple PHP and Laravel versions on push or pull request.
Extending Tests
When adding new features, please add corresponding tests in:
- Unit tests:
tests/Unit/
Installation
You can install the PDF Template package via Packagist:
1. Require the package via Composer
Run the following command in your project root:
composer require smarterp-dev/pdf-template
2. Publish the package views (optional)
If you want to customize the PDF templates, you can publish the package's views to your Laravel application's resources directory:
php artisan vendor:publish --tag=views
This will copy the package views to resources/views/vendor/smarterp-dev
.
To publish only the template views:
php artisan vendor:publish --tag=view-templates
This will copy the template views to resources/views/vendor/smarterp-dev/templates
.
To publish example template views:
php artisan vendor:publish --tag=view-examples
This will copy example templates to resources/views/vendor/smarterp-dev/templates/examples
.
3. Create the required temporary directory for mPDF
mPDF requires a writable temporary directory. Create it with:
mkdir -p temp/pdf
4. Configuration
The package will automatically register its service provider. No manual configuration is required for basic usage.
5. Ready to Use
You can now use the package in your Laravel application. For usage examples and API documentation, refer to docs/pdf.md and docs/template.md
License
MIT License. See LICENSE