@@ -8,230 +8,35 @@ Integration of the [**Geocoder**](http://github.com/willdurand/Geocoder) library
8
8
into Symfony2.
9
9
10
10
11
- Installation
12
- ------------
13
-
14
- Using Composer, just add the following configuration to your ` composer.json ` :
15
-
16
- ``` json
17
- {
18
- "require" : {
19
- "willdurand/geocoder-bundle" : " *"
20
- }
21
- }
22
- ```
23
-
24
- Register the bundle in ` app/AppKernel.php ` :
25
-
26
- // app/AppKernel.php
27
- public function registerBundles()
28
- {
29
- return array(
30
- // ...
31
- new Bazinga\Bundle\GeocoderBundle\BazingaGeocoderBundle(),
32
- );
33
- }
11
+ Documentation
12
+ -------------
34
13
14
+ For documentation, see:
35
15
36
- Usage
37
- -----
16
+ Resources/doc/
38
17
39
- This bundle registers a ` bazinga_geocoder.geocoder ` service which is an instance
40
- of ` Geocoder ` . You'll be able to do whatever you want with it.
41
-
42
- ** NOTE:** When using ` Request::getClientIp() ` with Symfony 2.1+, ensure you have a trusted proxy set in your
43
- ` config.yml ` :
44
-
45
- ``` yaml
46
- # app/config/config.yml
47
- framework :
48
- trusted_proxies : ['127.0.0.1']
49
- # ...
50
- ```
18
+ [ Read the documentation] ( https://github.com/willdurand/BazingaGeocoderBundle/blob/master/Resources/doc/index.md )
51
19
52
- #### Killer Feature ####
53
20
54
- You can fake the ` REMOTE_ADDR ` HTTP parameter through this bundle in order to get
55
- information in your development environment, for instance:
56
-
57
- ``` php
58
- <?php
59
-
60
- // ...
61
-
62
- /**
63
- * @Template()
64
- */
65
- public function indexAction()
66
- {
67
- // Retrieve information from the current user (by its IP address)
68
- $result = $this->geocoder
69
- ->using('yahoo')
70
- ->geocode($this->getRequest()->server->get('REMOTE_ADDR'));
71
-
72
- // Find the 5 nearest objects from the current user.
73
- $objects = ObjectQuery::create()
74
- ->filterByDistanceFrom($result->getLatitude(), $result->getLongitude(), 15)
75
- ->limit(5)
76
- ->find();
77
-
78
- return array(
79
- 'geocoded' => $result,
80
- 'nearest_objects' => $objects
81
- );
82
- }
83
- ```
21
+ Contributing
22
+ ------------
84
23
85
- In the example, we'll retrieve information from the user's IP address, and 5
86
- objects nears him.
87
- But it won't work on your local environment, that's why this bundle provides
88
- an easy way to fake this behavior by using a ` fake_ip ` parameter.
89
-
90
- ``` yaml
91
- # app/config/config_dev.yml
92
- bazinga_geocoder :
93
- fake_ip : 123.345.643.133
94
- ` ` `
95
-
96
- If set, the parameter will replace the ` REMOTE_ADDR` value by the given one.
97
-
98
- # # Dumpers ##
99
-
100
- If you need to dump your geocoded data to a specific format, you can use the
101
- __Dumper__ component. The following dumper's are supported :
102
-
103
- * Geojson
104
- * GPX
105
- * KMP
106
- * WKB
107
- * WKT
108
-
109
- Here is an example :
110
-
111
- ` ` ` php
112
- <?php
113
-
114
- public function geocodeAction()
115
- {
116
- $result = $this->container->get('bazinga_geocoder.geocoder')
117
- ->geocode($this->container->get('request')->server->get('REMOTE_ADDR'));
118
-
119
- $body = $this->container->get('bazinga_geocoder.dumper_manager')
120
- ->get('geojson')
121
- ->dump($result);
122
-
123
- $response = new Response();
124
- $response->setContent($body);
125
-
126
- return $response;
127
- }
128
- ` ` `
129
-
130
- To register a new dumper, you must tag it with _geocoder.dumper_.
131
- Geocoder detect and register it automaticly.
132
-
133
- A little example :
134
-
135
- ` ` ` xml
136
- <service id="some.dumper" class="%some.dumper.class">
137
- <tag name="geocoder.dumper" alias="custom" />
138
- </service>
139
- ` ` `
140
- Cache Provider
141
- ---------------
142
-
143
- Sometimes you have to cache the results from a provider. For this case the bundle provides
144
- a cache provider. The cache provider wraps another provider and delegate all calls
145
- to this provider and cache the return value.
146
-
147
- __Configuration example:__
148
-
149
- ` ` ` yaml
150
- services:
151
- acme_cache_adapter:
152
- class: "Doctrine\C ommon\C ache\A pcCache"
153
-
154
- bazinga_geocoder:
155
- providers:
156
- cache:
157
- adapter: acme_cache_adapter
158
- provider: google_maps
159
- google_maps: ~
160
- ` ` `
161
-
162
- > Tip: If you want to configure the cache adapter,
163
- > we recommend the [liip/doctrine-cache-bundle](https://github.com/liip/LiipDoctrineCacheBundle.git).
164
-
165
-
166
-
167
- Reference Configuration
168
- -----------------------
169
-
170
- You have to define the providers you want to use in your configuration.
171
- Some of them need information (API key for instance).
172
-
173
- You'll find the reference configuration below :
174
-
175
- ` ` ` yaml
176
- # app/config/config*.yml
177
-
178
- bazinga_geocoder:
179
- fake_ip: 999.999.999.999
180
- adapter:
181
- class: \Y our\C ustomAdapter
182
- providers:
183
- bing_maps:
184
- api_key: XXXXXXXXX
185
- locale: xx_XX
186
- google_maps:
187
- locale: xx_XX
188
- region: xx_XX
189
- ip_info_db:
190
- api_key: XXXXXXXXX
191
- yahoo:
192
- api_key: XXXXXXXXX
193
- locale: xx_XX
194
- cloudmade:
195
- api_key: XXXXXXXXX
196
- free_geo_ip: ~
197
- openstreetmaps:
198
- locale: xx_XX
199
- host_ip: ~
200
- geoip: ~
201
- mapquest: ~
202
- oiorest: ~
203
- geocoder_ca: ~
204
- geocoder_us: ~
205
- ign_openls:
206
- api_key: XXXXXXXXX
207
- data_science_toolkit: ~
208
- yandex:
209
- locale: xx-XX
210
- toponym: XXXXXXXXX
211
- geo_ips:
212
- api_key: XXXXXXXXX
213
- geo_plugin: ~
214
- maxmind:
215
- api_key: XXXXXXXXX
216
- # Caching Layer
217
- cache:
218
- provider: openstreetmaps
219
- adapter: some_service_id
220
- lifetime: 86400
221
- locale: %locale%
222
- chain:
223
- providers: [free_geo_ip, host_ip]
224
- ` ` `
24
+ See
25
+ [ CONTRIBUTING] ( https://github.com/willdurand/BazingaGeocoderBundle/blob/master/CONTRIBUTING.md )
26
+ file.
225
27
226
28
227
29
Credits
228
30
-------
229
31
230
- * William Durand <[email protected] >
32
+ * William Durand
231
33
* [ All contributors] ( https://github.com/willdurand/BazingaGeocoderBundle/contributors )
232
34
233
35
234
36
License
235
37
-------
236
38
237
- See `Resources/meta/LICENSE`.
39
+ This bundle is released under the MIT license. See the complete license in the
40
+ bundle:
41
+
42
+ Resources/meta/LICENSE
0 commit comments