Coder Social home page Coder Social logo

Comments (8)

oschwald avatar oschwald commented on July 18, 2024

Thanks for the report. How did you install the API? We already list the extension as a conflict in the composer.json file.

from geoip-api-php.

daigo75 avatar daigo75 commented on July 18, 2024

I'm not sure I understand the question correctly. I included the API (geop.inc etc) in a small software that I then package and distribute. The GeoIP library is included using Composer, but I can't predict if the environment where the package will be installed will contain the geoip php extension or not.

Please note that, when my package is installed, Composer is not used to update the dependencies (nor it should be). Vendor libraries, including GeoIP, are simply included in the package, which is then just unzipped and executed "as is".

from geoip-api-php.

oschwald avatar oschwald commented on July 18, 2024

Couldn't you check if the function exists before you load geoip.inc?

from geoip-api-php.

daigo75 avatar daigo75 commented on July 18, 2024

geoip.inc is loaded automatically by Composer, I don't have control over it. Also, that would not be a good workaround, because several, but not all of functions declared in geoip.inc match ones existing in geoip php extension.

A better workaround, which is what I've done at the moment, if check for the existence of every single function in geoip.inc. This, however, is still rough and far from optimal. A better solution would be replacing global functions with classes, or using namespaces. I understand that this would have the side effect of breaking compatibility with previous interfaces, but global functions are a legacy solution anyway and I don't think it makes sense to support PHP 4 anymore (Composer requires PHP 5.3 anyway).

from geoip-api-php.

oschwald avatar oschwald commented on July 18, 2024

We won't be redesigning the interface of this library as we are in the process of releasing a more modern GeoIP2 library, https://github.com/maxmind/GeoIP2-php.

We might consider merging a pull request with your other solution, but we would need to look at it more closely.

from geoip-api-php.

daigo75 avatar daigo75 commented on July 18, 2024

I saw the GeoIP2 library, I will probably switch to it when it will be ready.

Regarding the pull request, I don't think it would be necessary. I definitely don't recommend the solution I adopted, which is just an ugly hack that I put in place because I needed a solution quickly to prevent it from crashing my software.

Unfortunately, I don't see a reliable way to fix the incompatibility without a redesign. The geoip php extension offers some, but not all of the features of the GeoIP library (at least, not according to the documentation). Therefore, in their current status, a simply "one or the other" is the wrong logic and it won't work in many cases. If the two were fully overlapping, and providing the exact same functionalities, then it would be possible to add a simple check at the beginning of geoip.inc, such as:

if(extension_loaded('geoip')) {
  // geoip php extension loaded, don't load this library
return;
}

Since that is not the case, skipping the geoip.inc altogether in the presence of the php extension could cause unpredictable results.

from geoip-api-php.

oschwald avatar oschwald commented on July 18, 2024

Given that we don't have control over the extension and the extension has a different API, we are unable to fix this. The extension is already marked as conflicting in the composer.json file. If you want seamless transition between a C extension and a pure PHP implementation, we suggest that you use GeoIP2.

from geoip-api-php.

TokyoDesu avatar TokyoDesu commented on July 18, 2024

i can solved this problem i Got to my CPanel Choose version of PHP and select the actual and disable in the options geoip extension.

Now all work good =).

Only need check your hosting cpanel or if you have a vps only change your php.ini

from geoip-api-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.