PageRenderTime 28ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Project/faci-qsoft/wp-content/plugins/wp-statistics/vendor/maxmind-db/reader/README.md

https://gitlab.com/hop23typhu/list-theme
Markdown | 140 lines | 93 code | 47 blank | 0 comment | 0 complexity | 4909c6795ed1c9769aa1fbb11bb134a9 MD5 | raw file
  1. # MaxMind DB Reader PHP API #
  2. ## Description ##
  3. This is the PHP API for reading MaxMind DB files. MaxMind DB is a binary file
  4. format that stores data indexed by IP address subnets (IPv4 or IPv6).
  5. ## Installation ##
  6. We recommend installing this package with [Composer](http://getcomposer.org/).
  7. ### Download Composer ###
  8. To download Composer, run in the root directory of your project:
  9. ```bash
  10. curl -sS https://getcomposer.org/installer | php
  11. ```
  12. You should now have the file `composer.phar` in your project directory.
  13. ### Install Dependencies ###
  14. Run in your project root:
  15. ```
  16. php composer.phar require maxmind-db/reader:~1.0
  17. ```
  18. You should now have the files `composer.json` and `composer.lock` as well as
  19. the directory `vendor` in your project directory. If you use a version control
  20. system, `composer.json` should be added to it.
  21. ### Require Autoloader ###
  22. After installing the dependencies, you need to require the Composer autoloader
  23. from your code:
  24. ```php
  25. require 'vendor/autoload.php';
  26. ```
  27. ## Usage ##
  28. ## Example ##
  29. ```php
  30. <?php
  31. require_once 'vendor/autoload.php';
  32. use MaxMind\Db\Reader;
  33. $ipAddress = '24.24.24.24';
  34. $databaseFile = 'GeoIP2-City.mmdb';
  35. $reader = new Reader($databaseFile);
  36. print_r($reader->get($ipAddress));
  37. $reader->close()
  38. ```
  39. ## Optional PHP C Extension ##
  40. MaxMind provides an optional C extension that is a drop-in replacement for for
  41. `MaxMind\Db\Reader`. In order to use this extension, you must install the
  42. Reader API as described above and install the extension as described below. If
  43. you are using an autoloader, no changes to your code should be necessary.
  44. ### Installing Extension ###
  45. First install [libmaxminddb](https://github.com/maxmind/libmaxminddb) as
  46. described in its [README.md
  47. file](https://github.com/maxmind/libmaxminddb/blob/master/README.md#installing-from-a-tarball).
  48. After successfully installing libmaxmindb, run the following commands from the
  49. top-level directory of this distribution:
  50. ```
  51. cd ext
  52. phpize
  53. ./configure
  54. make
  55. make test
  56. sudo make install
  57. ```
  58. You then must load your extension. The recommend method is to add the
  59. following to your `php.ini` file:
  60. ```
  61. extension=maxminddb.so
  62. ```
  63. Note: You may need to install the PHP development package on your OS such as
  64. php5-dev for Debian-based systems or php-devel for RedHat/Fedora-based ones.
  65. ## 128-bit Integer Support ##
  66. The MaxMind DB format includes 128-bit unsigned integer as a type. Although
  67. no MaxMind-distributed database currently makes use of this type, both the
  68. pure PHP reader and the C extension support this type. The pure PHP reader
  69. requires gmp or bcmath to read databases with 128-bit unsigned integers.
  70. The integer is currently returned as a hexadecimal string (prefixed with "0x")
  71. by the C extension and a decimal string (no prefix) by the pure PHP reader.
  72. Any change to make the reader implementations always return either a
  73. hexadecimal or decimal representation of the integer will NOT be considered a
  74. breaking change.
  75. ## Support ##
  76. Please report all issues with this code using the [GitHub issue tracker]
  77. (https://github.com/maxmind/MaxMind-DB-Reader-php/issues).
  78. If you are having an issue with a MaxMind service that is not specific to the
  79. client API, please see [our support page](http://www.maxmind.com/en/support).
  80. ## Requirements ##
  81. This library requires PHP 5.3 or greater. Older versions of PHP are not
  82. supported. The pure PHP reader included with this library is works and is
  83. tested with HHVM.
  84. The GMP or BCMath extension may be required to read some databases
  85. using the pure PHP API.
  86. ## Contributing ##
  87. Patches and pull requests are encouraged. All code should follow the PSR-1 and
  88. PSR-2 style guidelines. Please include unit tests whenever possible.
  89. ## Versioning ##
  90. The MaxMind DB Reader PHP API uses [Semantic Versioning](http://semver.org/).
  91. ## Copyright and License ##
  92. This software is Copyright (c) 2014 by MaxMind, Inc.
  93. This is free software, licensed under the Apache License, Version 2.0.