Skip to content
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

Implement MaxData GeoIP2 provider and database adapter #303

Merged
merged 3 commits into from
Jun 13, 2014

Conversation

jenswiese
Copy link
Contributor

Update README.md, add requirements/suggest to composer.json.

Update README.md, add requirements/suggest to composer.json.
@jenswiese
Copy link
Contributor Author

Tests are running on my machine. ;) No, seriously I'm on fixing it.

@willdurand
Copy link
Member

Ok cool, really cool!

One thing though, while I thought it could have been a good idea to have a dedicated Adapter, it totally breaks the library's philosophy. For instance, you can't use this provider with the chain provider.

@jenswiese
Copy link
Contributor Author

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.

@willdurand
Copy link
Member

I'd like @toin0u and @Baachi POVs first :)

/**
* {@inheritdoc}
*/
public function __construct(HttpAdapterInterface $adapter, $locale = 'en')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not change the interface to GeoIP2DatabaseAdapter and remove the instanceof call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep BC and improve the adapter for the next major release.

@toin0u
Copy link
Member

toin0u commented Apr 22, 2014

@jenswiese I think it's a really good work :) 👍

@willdurand
Copy link
Member

Yeah, I like such contribution too! It just needs some more work to be mergeable :-)

@jenswiese
Copy link
Contributor Author

Hey guys,

thank you very much for your feedback!

Let me try to wrap it up:

  • Remove the trimming of the URL
  • You proposed to inject the GeoIP2\Database\Reader into the GeoIP2DatabaseAdapter. I would rather stick to passing on the database path. As I mentioned, I want to hide the dependency to the Reader for the user of the Geocoder library. Because he has to deal with the Adapter and the Provider, and that's it.

When it's okay for you, I will prepare the PR. Otherwise we have to discuss a little. ;)

Cheers Jens.

@toin0u
Copy link
Member

toin0u commented Apr 28, 2014

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 ?

@oschwald
Copy link
Contributor

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.

@jenswiese
Copy link
Contributor Author

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.

@toin0u
Copy link
Member

toin0u commented May 7, 2014

@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.
@willdurand
Copy link
Member

Looks promising!

@toin0u
Copy link
Member

toin0u commented May 15, 2014

Yay! I will be a great improvement :)

@willdurand
Copy link
Member

@jenswiese what's the status of your PR?

@jenswiese
Copy link
Contributor Author

Hey @willdurand, I considered this as finished. ;)

@toin0u
Copy link
Member

toin0u commented Jun 12, 2014

@jenswiese What about injecting the GeoIP2 dependency ?

@jenswiese
Copy link
Contributor Author

@toin0u, it's in 6b5bbd8

@toin0u
Copy link
Member

toin0u commented Jun 12, 2014

👍

willdurand added a commit that referenced this pull request Jun 13, 2014
Implement MaxData GeoIP2 provider and database adapter
@willdurand willdurand merged commit 12b862d into geocoder-php:master Jun 13, 2014
@willdurand
Copy link
Member

thank you @jenswiese!

willdurand added a commit that referenced this pull request Jun 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants