Download the PHP package omobude/dhl-symfony-bundle without Composer

On this page you can find all versions of the php package omobude/dhl-symfony-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dhl-symfony-bundle

DHL Symfony Bundle

PHP Version Symfony

Modern Symfony 7+ bundle for DHL API integration. Create shipment labels, view and download DHL shipments label with ease using OAuth authentication.

Features

Requirements

Table of Contents

Installation

Step 1: Install the Bundle

Step 2: Register the Bundle (If Not Auto-Registered)

If Symfony Flex doesn't automatically register the bundle, manually add it to config/bundles.php:

Note: With Symfony Flex, this step is usually automatic. Only add this manually if you encounter the error: "There is no extension able to load the configuration for 'omobude_dhl'".

Step 3: Configure Environment Variables

Add your DHL credentials to your .env file:

Step 4: Create Bundle Configuration

Create the file config/packages/omobude_dhl.yaml:

Step 5: Clear Cache

Getting DHL Credentials

For Sandbox (Testing)

  1. Go to DHL Developer Portal
  2. Sign up for a free account
  3. Create a new application
  4. Navigate to your application settings
  5. Copy your Client ID and Client Secret
  6. Use these credentials in your .env file

For Production

  1. Contact DHL to request production API access
  2. Complete any required business verification
  3. Receive your production Client ID and Client Secret
  4. Update your production environment variables
  5. Set sandbox: false in your configuration

Usage

Creating a Shipment

Northern Ireland Shipments (Clearance Declaration)

Shipments delivered to Northern Ireland (postcodes starting with BT) require an additional clearance declaration under the Windsor Framework / UK Internal Market Scheme (UKIMS). The bundle automatically detects Northern Ireland postcodes and will throw a BadRequestHttpException if a clearance declaration is missing.

When is a Clearance Declaration Required?

Destination Postcode Prefix Clearance Declaration
Great Britain (England, Scotland, Wales) Most UK postcodes โŒ Not required
Northern Ireland BT โœ… Required

Building a Clearance Declaration

A clearance declaration is composed of two model classes:

ClearanceDeclaration Fields

Field Type Required Description
shipmentMovementType string Yes Movement type โ€” B2C (business to consumer) or B2B (business to business)
totalValue float Yes Total declared value of goods (excluding shipping costs)
numberOfItems int Yes Total number of items across all line items
items ClearanceItem[] Yes Array of ClearanceItem objects, one per line item
sendersEORINumber string No Sender's EORI (Economic Operators Registration and Identification) number
sendersUKIMSNumber string No Sender's UKIMS (UK Internal Market Scheme) authorisation number

Note on EORI / UKIMS: Although marked optional in the model, most B2C movements into Northern Ireland under the Windsor Framework will require a valid UKIMS number to qualify for the green-lane "not at risk" treatment. Check your DHL contract and current HMRC guidance before omitting these fields.

ClearanceItem Fields

Field Type Required Description
descriptionOfGoods string Yes Plain-English description of the goods (e.g. "Cotton T-Shirt")
unitQuantity int Yes Quantity of this item being shipped
commodityCode string No HS / commodity tariff code (e.g. "6109100010"). Strongly recommended for customs clearance

Validation Behaviour

The bundle enforces clearance declaration rules at the point of calling toArray() on ShipmentData (which happens automatically inside DhlApiClient::createShipment()):

Always catch BadRequestHttpException separately if you want to surface clear validation errors to your users before the request hits the DHL API.

Downloading a Label

Checking Sandbox Mode

Configuration Reference

Option Type Required Default Description
client_id string Yes - Your DHL OAuth Client ID
client_secret string Yes - Your DHL OAuth Client Secret
sandbox boolean Yes Enable sandbox/testing mode

DHL Product Codes

Common product codes for orderedProduct:

Code Service Delivery Time
1 DHL Parcel Next day
48 DHL Parcel Neighbour 48 hours

Recipient Types

Valid values for recipientType:

Address Types

Valid values for addressType:

Shipment Movement Types

Valid values for ClearanceDeclaration::$shipmentMovementType:

Switching to Production

Step 1: Update Environment Variables

Update your production .env file:

Step 3: Clear Production Cache

Step 4: Test in Production

Always test with a single shipment first to ensure everything works correctly.

Troubleshooting

Bundle Not Registered

Problem: "There is no extension able to load the configuration for 'omobude_dhl'"

Solution:

  1. Ensure the bundle is registered in config/bundles.php:

  2. Clear the cache: php bin/console cache:clear
  3. Verify installation: composer show omobude/dhl-symfony-bundle

Authentication Errors

Problem: "Authentication failed" or "Invalid credentials"

Solution:

Configuration Errors

Problem: "The child config 'client_id' under 'omobude_dhl' must be configured"

Solution:

  1. Ensure config/packages/omobude_dhl.yaml exists
  2. Verify the configuration syntax is correct
  3. Check that environment variables are defined in .env
  4. Run php bin/console debug:config omobude_dhl to verify

Northern Ireland Clearance Errors

Problem: BadRequestHttpException: Clearance declaration is required for Northern Ireland deliveries (postcode: BT1 5GS).

Solution:

Token Caching Issues

Problem: "Cached token expired" or authentication errors after some time

Solution:

API Errors

Problem: DHL API returns error codes

Solution:

Debugging

Enable detailed logging:

Check logs:

Verify bundle configuration:

Environment-Specific Configuration

Development

Staging

Production

Security Best Practices

  1. Never commit credentials - Add .env to .gitignore
  2. Use environment variables - Store credentials in environment, not code
  3. Separate environments - Use different credentials for dev/staging/prod
  4. Monitor access logs - Check DHL dashboard for unusual activity
  5. Use HTTPS only - The bundle uses HTTPS by default
  6. Limit permissions - Only grant necessary access to DHL accounts

Recommended .gitignore

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Write tests for your changes
  5. Ensure all tests pass: ./vendor/bin/phpunit
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Open a Pull Request

Coding Standards

License

This bundle is released under the MIT License. See the LICENSE file for details.

Author

Omobude Kelly

Support

Need help? Here are your options:

Acknowledgments


Made with โค๏ธ for the Symfony community

If this bundle helped you, please consider giving it a โญ on GitHub!


All versions of dhl-symfony-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
psr/log Version ^3.0
symfony/cache Version ^7.0
symfony/framework-bundle Version ^7.0
symfony/http-client Version ^7.0
symfony/dependency-injection Version ^7.0
symfony/config Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package omobude/dhl-symfony-bundle contains the following files

Loading the files please wait ...