Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Bpost Address Webservice

Bpost Address Webservice Laravel Package

spatie/bpost-address-webservice

PHP wrapper for bpost’s Address Webservice. Create Address objects and validate Belgian addresses, receiving normalized fields plus warnings/errors/issue lists you can inspect and act on. Useful for checkout forms and address cleanup.

View on GitHub
Deep Wiki
Context7

An API wrapper for bpost's address webservice

Frequently asked questions about Bpost Address Webservice
How do I install and set up spatie/bpost-address-webservice in Laravel?
Run `composer require spatie/bpost-address-webservice` and register the service provider in `config/app.php`. Configure your Bpost API credentials (username/password) in `.env` under `BPOST_USERNAME` and `BPOST_PASSWORD`. The package integrates seamlessly with Laravel’s service container.
Does this package support Laravel 9 or 10? Will it break in newer versions?
The package is officially tested for Laravel 7/8 but may work with newer versions if no breaking changes are introduced. Check the [GitHub issues](https://github.com/spatie/bpost-address-webservice/issues) for compatibility reports. Test thoroughly in a staging environment before upgrading.
How do I validate an address in a Laravel Form Request?
Use the `AddressValidator` in your Form Request’s `validate()` method. For example, inject the validator via the constructor and call `$validator->validate($request->addressData)`. Return the errors/warnings to the user via `$validator->hasErrors()` or `$validator->errors()`.
What happens if Bpost’s API is down or rate-limited? Does the package handle retries?
The package does not include built-in retry logic or fallback mechanisms. You’ll need to implement caching (e.g., `Cache::remember()`) or a retry strategy (e.g., using `spatie/laravel-activitylog`). For high availability, consider a backup validator like Google Maps or manual validation.
Can I mock the Bpost API for unit testing? How do I test edge cases?
Use Laravel’s `Http` facade or Mockery to stub the Bpost API responses. For example, mock the `AddressValidator` to return predefined errors/warnings. Test edge cases like invalid postal codes, API timeouts, or malformed responses by simulating these scenarios in your tests.
Are there any rate limits or quotas I should know about for Bpost’s API?
Bpost’s API quotas are not documented in the package, but SOAP APIs often have strict limits (e.g., requests per minute). Monitor your API calls and implement caching for frequent addresses. Check Bpost’s official documentation or contact their support for exact limits.
Does this package work with non-Belgian addresses? Can I use it for international shipping?
No, this package is specifically for Belgian addresses (Bpost API). For international shipping, consider alternatives like Google Maps API or other country-specific address validation services. The package enforces Belgian postal code and municipality formats.
How do I handle authentication? Does the package support OAuth or token-based auth?
The package currently uses static username/password credentials configured in `.env`. If Bpost requires OAuth or token-based auth, you’ll need to extend the `AddressValidator` class or fork the package to support the new authentication method.
Can I store validated addresses in my database? How does this integrate with Eloquent?
Yes, you can store validated addresses in your database. The `ValidatedAddress` object can be converted to an array with `$validatedAddress->toArray()`. Extend your Eloquent models (e.g., `Customer`) to use the validator in accessors or observers for automatic validation.
What are the alternatives to spatie/bpost-address-webservice for Belgian address validation?
If this package doesn’t meet your needs, consider direct SOAP integration using `php-soap` or libraries like `wsdl2php`. For broader address validation, use Google Maps API or PostcodeAnywhere. However, none of these will enforce Belgian postal regulations as strictly as Bpost’s official API.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport