netbrothers-gmbh / nb-googleapi-bundle
用于调用 GoogleMaps 的 SymfonyBundle
dev-main
2024-05-23 11:13 UTC
Requires
- php: >=8.2
- ext-json: *
- ramsey/uuid: *
- symfony/console: *
- symfony/http-client: *
- symfony/serializer: *
- symfony/string: *
- symfony/yaml: *
This package is auto-updated.
Last update: 2024-09-23 12:35:39 UTC
README
这个用于 Symfony 的小库可以向 GoogleMaps 地点自动完成发送请求。
安装
请确保已全局安装 Composer,具体说明请参阅 Composer 文档中的安装章节。
使用 Symfony Flex 的应用程序
打开命令行,进入您的项目目录并执行以下命令
composer require netbrothers-gmbh/nb-google-api
未使用 Symfony Flex 的应用程序
步骤 1: 下载 Bundle
打开命令行,进入您的项目目录并执行以下命令以下载此 Bundle 的最新稳定版本
composer require netbrothers-gmbh/nbcsb-bundle
步骤 2: 启用 Bundle
然后,通过将其添加到项目 config/bundles.php
文件中注册的 Bundle 列表中来启用该 Bundle
// config/bundles.php return [ // ... NetBrothers\NbGoogleApiBundle\NbGoogleApiBundle::class => ['all' => true], ];
配置
- 将
install/config/packages/netbrothers_google_api.yaml
复制到 Symfony 的配置路径 - 将所需值添加到您的
.env
文件中(请参阅 install/env.default)
###> netbrothers-gmbh/netbrothers_google_api ###
NB_GOOGLE_API_ENABLE=1
NB_GOOGLE_API_PLACES_AUTOCOMPLETE_URI=https://maps.googleapis.com/maps/api/place/autocomplete/
NB_GOOGLE_API_PLACES_AUTOCOMPLETE_REQUEST_TYPE=json
NB_GOOGLE_PLACES_AUTOCOMPLETE_API_KEY=YOUR_API_KEY
###< netbrothers-gmbh/netbrothers_google_api ###
- 清除 Symfony 的缓存。
使用方法
首先运行示例命令 bin/console netbrothers:example:google-autocomplete
。还可以查看 example/ExampleController.php
作者
Stefan Wessel, NetBrothers GmbH
许可证
MIT