cable8mm / waybill
A lightweight PHP library for generating PDF waybills with ease.
Requires
- php: ^8.2
- cable8mm/stub-template: ^1.0
- fakerphp/faker: ^1.0
- mbezhanov/faker-provider-collection: ^2.0
- mpdf/mpdf: ^8.0|^8.1
- picqer/php-barcode-generator: ^3.2
Requires (Dev)
- laravel/pint: ^1.20
- phpunit/phpunit: ^9.0|^10.0|^11.0
Suggests
- cable8mm/stub-template: Provide template functions for stub files
- fakerphp/faker: Provide faker methods for factories
- laravel/pint: Provide a easy way to fit coding style
- mbezhanov/faker-provider-collection: Provide faker methods for companies and products
- mpdf/mpdf: Provide pdf functions for creating waybills
- picqer/php-barcode-generator: Provide barcode generator for creating waybills
This package is auto-updated.
Last update: 2025-02-16 05:40:25 UTC
README
A lightweight PHP library for generating PDF waybills with ease. This package allows developers to create and customize waybills in PDF format for courier and logistics services. It supports barcode generation, sender/receiver details, and customizable layouts. Perfect for automating shipping label creation in your e-commerce or logistics applications.
Installation
You can install the package via composer:
composer require cable8mm/waybill
Usage
Save a waybill for pdf format:
use Cable8mm\Waybill\Enums\ParcelService; use Cable8mm\Waybill\Waybill; Waybill::of(ParcelService::Cj) ->path(realpath(__DIR__.'/../dist')) ->save('test.pdf');
Get a waybill array:
$waybill = Waybill::of(ParcelService::Cj) ->toArray()
Save multiple waybills for pdf format:
$mpdf = Mpdf::instance(); WaybillCollection::of(mpdf: $mpdf) ->add(Waybill::of(ParcelService::Cj, mpdf: $mpdf)) ->add(Waybill::of(ParcelService::Cj, mpdf: $mpdf)) ->path(realpath(__DIR__.'/../dist')) ->save('collection.pdf'); // or WaybillCollection::of(mpdf: $mpdf) ->add([ Waybill::of(ParcelService::Cj, mpdf: $mpdf), Waybill::of(ParcelService::Cj, mpdf: $mpdf), ]) ->path(realpath(__DIR__.'/../dist')) ->save('collection.pdf');
Slice the page of the waybills:
Slicer::of(ParcelService::Cj, 1) ->source('source.pdf') ->save('one_page.pdf'); // or `->download('one_page.pdf')`
How to customize
If you want to add another parcel service like UPS, you would need to make Enums
and Factory
class, for example:
- Make
UpsFactory.php
into `src/Factories' folder. - Make
Enum
element intosrc/Enums
folder.
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email cable8mm@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.