-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MaxMindBinaryProvider, GeoIP and GeoIP2 #302
Comments
Agreed. I think it's a good idea to do so (as we need before). |
Hey William, first of all: great library! I really appreciate your work. My question: Do you plan to implement the MaxMindBinary2Provider in the near future? Do you need support? I guess I would implement a provider on my own anyways, because we need this. Maybe I could contribute something. ;) Best Regards, Jens. |
Hi @jenswiese, I think @willdurand will appreciate a PR :) No doubt about it ! |
Yup, feel free to implement this new provider! <3 |
Hey @willdurand, I'm actually on it. :) But I'm struggling with two approaches right now. Unlike the other providers, the MaxMind provider operates on a database file, that has to be passed to the provider. As I noticed the existing MaxMind provider gets a string via the constructor - fine, it works with the current PHP version. But it might break with the following, since the signature of the concrete implementation differs from the abstract (HttpAdapterInterface vs. string). How to solve this issue: 1.) Easy way, without harming the existing code Decouple the new GeoIP2 provider from the existing AbstractProvider, and implement just the provider interface. Implement a GeoIPDatabaseAdapter, that encapsulates the database reading (provided by the Maxmind DatabaseReader) - the adapter is not implementing the HttpAdapterInterface, because it's not a Http request. 2.) Hard way, with harming a lot of existing code Rename HttpAdapterInterface to AdapterInterface. Change the constructor signature of the AbstractProvider to something like this:
Change all existing adapters to implement the AdapterInterface, and finally rename the directory "HttpAdapter" to "Adapter". The GeoIP2Adapter would implement the same interface as the HttpAdapters then. What do you think? I didn't mean to break your whole library - sorry! :) I just wanted to share my thoughts. Maybe you have another great idea to solve this problem. Thanks so far, Jens. |
Hey @willdurand, regarding my post above, I think I found a better way to combine the best of the two approaches - without messing with the existing code to much. (https://github.com/jenswiese/Geocoder/tree/geoip2) I will buzz you, when I finished implementing it. Thanks Jens. |
As mentioned in #301, the current implementation of
MaxMindBinaryProvider
is far from perfect. This is mostly because of thegeoip/geoip
package we use under the hood.Obviously there is a newer lib, named
geoip2/geoip2
, which would be better. I'd like to switch to this package, but it would imply a BC break, so I suggest the introduction of a new provider (GeoIP2Provider
?MaxMindBinary2Provider
?) leveraging thegeoip2/geoip2
lib. Also, we should markMaxMindBinaryProvider
as deprecated.WDYT?
The text was updated successfully, but these errors were encountered: