api-postcode / api-postcode-bundle
Symfony Api Postcode 包
1.0.7
2022-07-11 10:56 UTC
Requires
- php: >=7.1.0
- ext-json: *
- api-postcode/php-client: ^1.0
- symfony/framework-bundle: ^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0
Requires (Dev)
- phpunit/phpunit: ^6.0
This package is not auto-updated.
Last update: 2024-09-19 08:12:09 UTC
README
此包可以用于通过邮编号码获取地址详情。
更多信息请见: https://api-postcode.nl
安装
安装是一个简单的3步过程
- 使用composer下载api-postcode-bundle
- 在AppKernel.php中启用Bundle
- 配置Api Postcode凭证
步骤1:使用composer下载postcode-bundle
运行以下命令添加ApiPostcodeBundle
$ composer require api-postcode/api-postcode-bundle
步骤2:在AppKernel.php中启用Bundle
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new ApiPostcode\PostcodeBundle\ApiPostcodeBundle(), ); }
步骤3:配置Api Postcode凭证
# app/config/config.yml # Api Postcode Token api_postcode: token: secret-token
使用服务
$address = $this->get('api.postcode')->fetchAddress('1012JS', 1); $address->getStreet(); // Dam $address->getCity(); // Amsterdam $address->getHouseNumber(); // 1 $address->getZipCode(); // 1012JS $address->getLongitude(); // 4.4584 $address->getLatitude(); // 52.2296
通过API使用
或者尝试API响应