A Laravel package for generating PDF documents using mPDF with Khmer font support and custom templates.
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
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
To generate an HTML test coverage report, run:
composer test-coverage
This will create HTML reports in the coverage
directory.
GitHub Actions workflow in .github/workflows/run-tests.yml
automatically runs tests across multiple PHP and Laravel versions on push or pull request.
When adding new features, please add corresponding tests in:
- Unit tests:
tests/Unit/
You can install the PDF Template package via Packagist:
Run the following command in your project root:
composer require smarterp-dev/pdf-template
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
.
mPDF requires a writable temporary directory. Create it with:
mkdir -p temp/pdf
The package will automatically register its service provider. No manual configuration is required for basic usage.
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
MIT License. See LICENSE