ialpro/bundesland
Composer 安装命令:
composer require ialpro/bundesland
包简介
Lookup German Bundesland (state) by ZIP (and optional city) via Zippopotam.us.
关键字:
README 文档
README
A Laravel package to look up the German Bundesland (federal state) by postal code (PLZ), optionally verifying the city, using the Zippopotam.us API.
It provides a Facade, global helper, and optional API route — with caching for efficiency.
🚀 Installation
Require the package via Composer:
composer require ialpro/bundesland
⚙️ Configuration
Publish the config (optional):
php artisan vendor:publish --tag=bundesland-config
This will create config/zippopotam.php:
return [ 'base_url' => env('ZIPPOPOTAM_BASE_URL', 'https://api.zippopotam.us'), 'country' => env('ZIPPOPOTAM_COUNTRY', 'de'), 'timeout' => (int) env('ZIPPOPOTAM_TIMEOUT', 5), 'cache_ttl' => (int) env('ZIPPOPOTAM_CACHE_TTL', 21600), // 6h 'enable_api_route' => (bool) env('BUNDESLAND_ENABLE_API', false), ];
🧑💻 Usage
Using the Facade
use Ialpro\Bundesland\Facades\ZipLookup; // Get Bundesland directly $state = ZipLookup::stateByZip('10115'); // "Berlin" // Full lookup with city check $res = ZipLookup::lookup('80331', 'München'); if ($res->ok) { echo $res->state; // "Bayern" } else { echo $res->message; // e.g. "City does not match ZIP" }
Using the Helper
$state = bundesland('20095'); // "Hamburg" $stateWithCheck = bundesland('80331','München'); // "Bayern"
In Blade
<p>ZIP 10115 → {{ bundesland('10115') }}</p> <p>ZIP 80331 + München → {{ bundesland('80331', 'München') }}</p>
🌐 Optional API Route
Enable in .env:
BUNDESLAND_ENABLE_API=true
This activates:
GET /api/bundesland/{zip}
Example:
GET /api/bundesland/10115 { "zip": "10115", "state": "Berlin" }
🧪 Testing
You can test with Orchestra Testbench.
Example:
public function test_lookup_berlin() { $state = \Ialpro\Bundesland\Facades\ZipLookup::stateByZip('10115'); $this->assertEquals('Berlin', $state); }
📜 License
MIT © Al Amin
ialpro/bundesland 适用场景与选型建议
ialpro/bundesland 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 36 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「zip」 「germany」 「bundesland」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ialpro/bundesland 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ialpro/bundesland 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ialpro/bundesland 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Allow packages to be installed from a repository or tarball bundle that have multiple packages in the sub-folders
Iteration tools for PHP
Convert and operate with FIPS codes for states, counties, etc.
Checks a VAT-ID using the eVatR REST-API of the German Federal Central Tax Office (Bundeszentralamt für Steuern, BZSt)
Smart compressed files extractor
Validates the German Tax-ID (Steuerliche Identifikationsnummer)
统计信息
- 总下载量: 36
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-29