shivella / postcode-bundle
Symfony Postcode 包
1.0.7
2021-03-13 19:38 UTC
Requires
- php: >=5.4
- guzzlehttp/guzzle: ^6.2
- symfony/framework-bundle: ^2.7 || ^3.0 || ^4.0
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-14 19:58:34 UTC
README
此包可用于通过邮编数字获取地址详情。需要Apiwise账户。更多信息请参阅:https://www.postcodeapi.nu
安装
安装是一个快速的四步过程
- 使用composer下载postcode-bundle
- 在AppKernel.php中启用Bundle
- 配置Apiwise凭据
- 添加路由
第一步:使用composer下载postcode-bundle
运行命令添加UsoftPostcodeBundle
$ composer require shivella/postcode-bundle
第二步:在AppKernel.php中启用Bundle
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Usoft\PostcodeBundle\UsoftPostcodeBundle(), ); }
第三步:配置Apiwise凭据
# app/config/config.yml # Apiwise Postcode API usoft_postcode: apiwise: key: secret_api_wise_key
第四步:添加路由
# app/config/routing.yml postcode: resource: "@UsoftPostcodeBundle/Resources/config/routing.yml" prefix: /
服务使用
$address = $this->get('usoft.postcode.client')->getAddress('1012JS', 1); $address->getStreet(); // Dam $address->getCity(); // Amsterdam $address->getMunicipality(); // Amsterdam $address->getProvince(); // Noord-Holland $address->getNumber(); // 1 $address->getZipcode(); // 1012JS $address->getGeoLocation(); // array('latitude' => 52.3732926, 'longitude' => 4.8937176)
通过API使用
或尝试API响应