schoenef / here-api-connector-bundle
允许在symfony项目中轻松使用https://developer.here.com/documentation#geocoder的here地理位置API。
v1.1.2
2020-09-05 13:21 UTC
Requires
- php: >=5.6
- schoenef/here-api-connector: ^1.0
- symfony/framework-bundle: >=2
This package is auto-updated.
Last update: 2024-09-19 22:26:02 UTC
README
允许在symfony项目中轻松使用here 地理位置 和 自动完成API。
您需要APP ID和APP代码才能使用此服务。这只是一个简单的包装,以便在symfony环境中访问。
该Bundle将Here API的结果转换为geojson,以便与其他API无缝工作。
安装
步骤 1:下载Bundle
打开命令行,进入您的项目目录,并执行以下命令以下载此bundle的最新稳定版本
$ composer require schoenef/here-api-connector-bundle:~1.1
此命令要求您全局安装Composer,如Composer文档中的安装章节中所述。
步骤 2:启用Bundle
然后,通过将其添加到项目app/AppKernel.php
文件中注册的bundle列表中来启用bundle
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Schoenef\HereApiConnectorBundle\HereApiConnectorBundle(), // here api geo coding service wrapper ); // ... } // ... }
步骤 3:配置Bundle
将以下配置添加到您的app/config/config.yml
here_api_connector: timeout: 20 app_code: "%here_api_app_code%" app_id: "%here_api_app_id%" lang: de country: DE
使用方法
要使用此连接器,您可以在symfony控制器中使用以下内容
$connector = $this->get('here_api.connector'); $results = $connector->searchLocation('ber'); // do some filtering $favoriteResult = $results[0]; // get the full place data $details = $connector->getDetails($favoriteResult->getId());