Implement MaxData GeoIP2 provider and database adapter#303
Implement MaxData GeoIP2 provider and database adapter#303willdurand merged 3 commits intogeocoder-php:masterfrom
Conversation
Update README.md, add requirements/suggest to composer.json.
|
Tests are running on my machine. ;) No, seriously I'm on fixing it. |
|
Ok cool, really cool! One thing though, while I thought it could have been a good idea to have a dedicated |
|
Hey @willdurand, how should we proceed with this PR? I guess I didn't get the point. Do you consider this provider breaking the library's philosophy, or what I mentioned before in #302 ? Please let me know, whether I can adapt/fix/change something to meet your requirements better. Thanks Jens. |
There was a problem hiding this comment.
Why not change the interface to GeoIP2DatabaseAdapter and remove the instanceof call?
There was a problem hiding this comment.
Good point!
This is exactly what I was struggling with in #302 . The main problem is that the AbstractProvider defines the constructor signature. Thus I was about to propose to change the typehint to something like AdapterInterface in order to have the ability to use a different adapter. But that would mean that we have to adapt all the HttpAdapters, as well as the directory structure/namespaces to unify that.
But as @willdurand mentioned that would break the library's philosophy.
There was a problem hiding this comment.
I think we should keep BC and improve the adapter for the next major release.
|
@jenswiese I think it's a really good work :) 👍 |
|
Yeah, I like such contribution too! It just needs some more work to be mergeable :-) |
|
Hey guys, thank you very much for your feedback! Let me try to wrap it up:
When it's okay for you, I will prepare the PR. Otherwise we have to discuss a little. ;) Cheers Jens. |
|
Hi @jenswiese, First of all thanks for you work ! It's really great :) According to the PR, I see your point but I think like a special provider, a special configuration is ok if we can remove the complexity by using DI. But it's only my POV. WDYT @willdurand @Baachi ? |
|
I only skimmed this, but if you go the DI route, you could allow the injection of a GeoIp2\ProviderInterface, which will support both the GeoIP2 database and web service. |
|
I consider what @oschwald mentioned as a good point and pro injecting the GeoIP2 dependency. When nobody has any concerns I would go that way, and go with the more generic approach. Cheers Jens. |
|
@jenswiese @oschwald I think it's a good idea :) |
Instead of using only the database reader of Maxmind, inject the Maxmind provider. Thus both is available: database reader and webservice client.
|
Looks promising! |
|
Yay! I will be a great improvement :) |
|
@jenswiese what's the status of your PR? |
|
Hey @willdurand, I considered this as finished. ;) |
|
@jenswiese What about injecting the GeoIP2 dependency ? |
|
👍 |
Implement MaxData GeoIP2 provider and database adapter
Update README.md, add requirements/suggest to composer.json.