{"id":21524217,"url":"https://github.com/mvdnbrk/dhlparcel-php-api","last_synced_at":"2025-04-03T03:10:06.708Z","repository":{"id":34221772,"uuid":"171006427","full_name":"mvdnbrk/dhlparcel-php-api","owner":"mvdnbrk","description":"DHL Parcel API client for PHP","archived":false,"fork":false,"pushed_at":"2024-05-15T10:17:11.000Z","size":388,"stargazers_count":38,"open_issues_count":12,"forks_count":29,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-24T07:58:58.576Z","etag":null,"topics":["api","dhl","dhl-parcel","dhl-parcel-client","parcel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvdnbrk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"mvdnbrk"}},"created_at":"2019-02-16T13:23:40.000Z","updated_at":"2025-01-19T17:57:56.000Z","dependencies_parsed_at":"2024-06-18T20:09:09.650Z","dependency_job_id":"3fb0d3a9-68fd-4513-adef-28b427807da9","html_url":"https://github.com/mvdnbrk/dhlparcel-php-api","commit_stats":{"total_commits":301,"total_committers":6,"mean_commits":"50.166666666666664","dds":0.02657807308970095,"last_synced_commit":"ea53200b9152fe08870d5169b1fcf7c74cf2ecff"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdnbrk%2Fdhlparcel-php-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdnbrk%2Fdhlparcel-php-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdnbrk%2Fdhlparcel-php-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvdnbrk%2Fdhlparcel-php-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvdnbrk","download_url":"https://codeload.github.com/mvdnbrk/dhlparcel-php-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246927835,"owners_count":20856198,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","dhl","dhl-parcel","dhl-parcel-client","parcel","php"],"created_at":"2024-11-24T01:22:54.295Z","updated_at":"2025-04-03T03:10:06.673Z","avatar_url":"https://github.com/mvdnbrk.png","language":"PHP","readme":"# DHL Parcel API client for PHP\n\n![PHP version][ico-php-version]\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Tests][ico-tests]][link-tests]\n[![Code style][ico-code-style]][link-code-style]\n[![Total Downloads][ico-downloads]][link-downloads]\n\n[DHL Parcel API documentation](https://api-gw.dhlparcel.nl/docs/)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require mvdnbrk/dhlparcel-php-api\n```\n\n## Usage\n\nInitialize the DHL Parcel client and set your credentials.\n\n``` php\n$dhlparcel = new \\Mvdnbrk\\DhlParcel\\Client();\n\n$dhlparcel-\u003esetUserId('your-user-id');\n$dhlparcel-\u003esetApiKey('your-api-key');\n```\n\nIf you have multipe accounts, you may optionally set an account id:\n\n```\n$dhlparcel-\u003esetAccountId('123456');\n```\n\n### Create a parcel\n\n```php\n$parcel = new \\Mvdnbrk\\DhlParcel\\Resources\\Parcel([\n    'reference' =\u003e 'your own reference for the parcel (optional)',\n    'recipient' =\u003e [\n        'first_name' =\u003e 'John',\n        'last_name' =\u003e 'Doe',\n        'street' =\u003e 'Poststraat',\n        'number' =\u003e '1',\n        'number_suffix' =\u003e 'A',\n        'postal_code' =\u003e '1234AA',\n        'city' =\u003e 'Amsterdam',\n        'cc' =\u003e 'NL',\n    ],\n    'sender' =\u003e [\n        'company_name' =\u003e 'Your Company Name',\n        'street' =\u003e 'Pakketstraat',\n        'additional_address_line' =\u003e 'Industrie 9999',\n        'number' =\u003e '99',\n        'postal_code' =\u003e '9999AA',\n        'city' =\u003e 'Amsterdam',\n        'cc' =\u003e 'NL',\n    ],\n    // Optional. This will be set as the default.\n    'pieces' =\u003e [\n        [\n            'parcel_type' =\u003e \\Mvdnbrk\\DhlParcel\\Resources\\Piece::PARCEL_TYPE_SMALL,\n            'quantity' =\u003e 1,\n        ],\n    ],\n]);\n```\n\n### Create the shipment\n\n``` php\n$shipment = $dhlparcel-\u003eshipments-\u003ecreate($parcel);\n\n$shipment-\u003eid;\n// For shipments with multiple pieces:\n$shipment-\u003epieces-\u003eeach(function ($item) {\n    $item-\u003elabel_id;\n    $item-\u003ebarcode;\n})\n// For a shipment with one single piece:\n$shipment-\u003elabel_id;\n$shipment-\u003ebarcode;\n```\n\n### Retrieving a label\n\nA label can be retrieved by using the `label_id`.\nThis will return a PDF label as a string.\n\n```\n$dhlparcel-\u003elabels-\u003eget($shipment-\u003elabel_id);\n```\n\nOr you may pass the `Shipment` instance directly to this method:\n\n```\n$dhlparcel-\u003elabels-\u003eget($shipment);\n```\n\n\u003e Passing a `Shipment` instance will only retrieve the label for a shipment with a single piece, or the first piece if you have created a shipment with multple pieces. If you have created a shipment with multiple pieces you should retrieve the labels one by one for each piece your shipment contains.\n\n### Setting delivery options for a parcel\n\nYou can set delivery options for a parcel by passing in the options directly when you create a parcel:\n\n``` php\n$parcel = new \\Mvdnbrk\\MyParcel\\Resources\\Parcel([\n    ...\n    'recipient' =\u003e [\n        ...\n    ],\n    'options' =\u003e [\n        'description' =\u003e 'Order #123',\n        'signature' =\u003e true,\n        'only_recipient' =\u003e true,\n        'cash_on_delivery' =\u003e 9.95,\n        'evening_delivery' =\u003e true,\n        'extra_assurance' =\u003e true,\n        ...\n    ],\n]);\n```\n\nOr you may use a method like `signature()` and others after constructing the parcel:\n\n``` php\n$parcel-\u003eonlyRecipient()\n       -\u003esignature()\n       -\u003elabelDescription('Order #123')\n       -\u003ecashOnDelivery(9.95)\n       -\u003eeveningDelivery()\n       -\u003eextraAssurance();\n```\n\n**Mailbox package**\n\nIf you would like to send a parcel that fits in a standard mailbox you may use the `mailboxpackage()` method:\n\n``` php\n$parcel-\u003emailboxpackage();\n```\n\n**Deliver a parcel to a DHL service point**\n\nYou may send a parcel to a DHL service point where a customer can pick up the parcel.\nThe ID of the service point can be set directly when creating a parcel\nor with the `servicePoint` method:\n\n``` php\n$parcel = new \\Mvdnbrk\\MyParcel\\Resources\\Parcel([\n    ...\n    'options' =\u003e [\n        'service_point_id' =\u003e '8004-NL-272403',\n        ...\n    ],\n]);\n\n$parcel-\u003eservicePoint('8004-NL-272403');\n```\n\n### Tracking a shipment\n\n``` php\n$tracktrace = $dhlparcel-\u003etracktrace-\u003eget('JVGL...');\n\n// Check if the shipment is delivered:\n$tracktrace-\u003eisDelivered;\n```\n\n### Retrieving service points\n\n```php\n$servicepoints = $dhlparcel-\u003eservicePoints-\u003esetPostalcode('1012AA')-\u003esetHousenumber('1')-\u003eget();\n```\n\nThis will return a collection of `ServicePoint` objects:\n\n```\n$servicepoints-\u003eeach(function ($item) {\n    $item-\u003eid;\n    $item-\u003ename;\n    $item-\u003elatitude;\n    $item-\u003elongitude;\n    $item-\u003edistance;\n    $item-\u003edistanceForHumans();\n});\n```\n\n## Usage with Laravel\n\nYou may incorporate this package in your Laravel application by using [this package](https://github.com/mvdnbrk/laravel-dhlparcel).\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Mark van den Broek](https://github.com/mvdnbrk)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-php-version]: https://img.shields.io/packagist/php-v/mvdnbrk/dhlparcel-php-api?style=flat-square\n[ico-version]: https://img.shields.io/packagist/v/mvdnbrk/dhlparcel-php-api.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-tests]: https://img.shields.io/github/workflow/status/mvdnbrk/dhlparcel-php-api/tests/main?label=tests\u0026style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/mvdnbrk/dhlparcel-php-api.svg?style=flat-square\n[ico-code-style]: https://styleci.io/repos/171006427/shield?branch=main\n\n[link-packagist]: https://packagist.org/packages/mvdnbrk/dhlparcel-php-api\n[link-tests]: https://github.com/mvdnbrk/dhlparcel-php-api/actions?query=workflow%3Atests\n[link-downloads]: https://packagist.org/packages/mvdnbrk/dhlparcel-php-api\n[link-author]: https://github.com/mvdnbrk\n[link-contributors]: ../../contributors\n[link-code-style]: https://styleci.io/repos/171006427\n","funding_links":["https://github.com/sponsors/mvdnbrk"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdnbrk%2Fdhlparcel-php-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvdnbrk%2Fdhlparcel-php-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvdnbrk%2Fdhlparcel-php-api/lists"}