diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..99bafec --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ +name: PHP Tests + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: bcmath, curl, json + coverage: none + + - name: Install Composer dependencies + run: | + if [ "${{ matrix.php-version }}" = "7.2" ]; then + composer require --dev phpunit/phpunit:^8.0 --no-update + fi + composer install --no-progress --prefer-dist + + - name: Run tests + run: vendor/bin/phpunit diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..7728509 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,32 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the OS, Python version and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.11" + # You can also specify other tool versions: + # nodejs: "19" + # rust: "1.64" + # golang: "1.19" + +# Build documentation in the "docs/" directory with Sphinx +sphinx: + configuration: docs/source/conf.py + +# Optionally build your docs in additional formats such as PDF and ePub +# formats: +# - pdf +# - epub + +# Optional but recommended, declare the Python requirements required +# to build your documentation +# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html +python: + install: + - requirements: docs/requirements.txt \ No newline at end of file diff --git a/LICENSE.TXT b/LICENSE.TXT index 3f56aae..5391874 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 IP2Location.com +Copyright (c) 2023 - 2025 IP2Location.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 53ae89a..9888b2e 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ IP2Location (PHP Module) *This is the official release maintained by IP2Location.com* -This PHP module provides fast lookup of country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection speed, IDD code, area code, weather station code, weather station name, MNC, MCC, mobile brand, elevation, usage type, address type and IAB category from IP address by using IP2Location database. This module uses a file based database available at IP2Location.com. +This PHP module provides fast lookup of country, region, district, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection speed, IDD code, area code, weather station code, weather station name, MNC, MCC, mobile brand, elevation, usage type, address type, IAB category and ASN from IP address by using IP2Location database. This module uses a file based database available at IP2Location.com. This module can be used in many types of projects such as: @@ -29,81 +29,9 @@ Monthly update is available for both IP2Location LITE and commercial database. 2. **Extensible.** If you require different granularity of IP information, you can visit [IP2Location.com](https://www.ip2location.com/databases) to download the relevant BIN file, and the information will made ready for you. 3. **Comprehensive Information.** There are more than 13 types of information that you can retrieve from an IP address. Please visit [IP2Location.com](https://www.ip2location.com/databases) for details. -## INSTALLATION - -Install this package using **composer** as below: - -``` -composer require ip2location/ip2location-php -``` - -To test this installation, please browse examples/example.php using web browser. - -## USAGE - -You can check the **example.php** file to learn more about usage. - -### Database Class -Below is the description of the functions available in the **Database** class. - -| Function Name | Description | -|---|---| -|Constructor|Expect 2 input parameters:
  1. Full path of IP2Location BIN data file.
  2. File Open Mode
For SHARED_MEMORY and MEMORY_CACHE, it will require your server to have sufficient memory to hold the BIN data, otherwise it will raise the errors during the object initialization.| -|**string** getDate()|Return the database's compilation date as a string of the form 'YYYY-MM-DD'| -|**string** getType()|Return the database's type, 1 to 25 respectively for DB1 to DB25. Please visit https://www.ip2location.com/databases for details.| -|**string** getModuleVersion()|Return the version of module| -|**string** getDatabaseVersion()|Return the version of database| -|**array** lookup($ip)|Return the IP information in array. Below is the information returned:You can visit [IP2Location](https://www.ip2location.com/databases/db25-ip-country-region-city-latitude-longitude-zipcode-timezone-isp-domain-netspeed-areacode-weather-mobile-elevation-usagetype-addresstype-category) for the description of each field. Note: although the above names are not exactly matched with the names given in this link, but they are self-described.| -|**array** getCidr($ip)|Return an array of the complete IP list in CIDR format of the detected row record based on the given IP address.| - - -### WebService Class -Below is the description of the functions available in the **WebService** class. - -| Function Name | Description | -| --------------------- | ------------------------------------------------------------ | -| Constructor | Expect 3 input parameters:
  1. IP2Location API Key.
  2. Package (WS1 - WS25)
  3. Use HTTPS or HTTP
| -| **array** lookup($ip) | Return the IP information in array.