{"id":21945860,"url":"https://github.com/ip2location/ip2location-cakephp","last_synced_at":"2025-05-07T04:07:49.375Z","repository":{"id":41562702,"uuid":"20321171","full_name":"ip2location/ip2location-cakephp","owner":"ip2location","description":"IP2Location CakePHP plugin enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation, usage type, IP address type and IAB advertising category from IP address using IP2Location database.","archived":false,"fork":false,"pushed_at":"2024-10-04T04:57:19.000Z","size":754,"stargazers_count":19,"open_issues_count":0,"forks_count":6,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-06T09:02:26.315Z","etag":null,"topics":["cakephp","geolocation","ip-address-database","ip-database","ip-geolocation","ip-lookup","ip2location","ip2location-bin-databases","ip2location-cakephp"],"latest_commit_sha":null,"homepage":"http://www.ip2location.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ip2location.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2014-05-30T07:43:26.000Z","updated_at":"2024-12-11T21:43:46.000Z","dependencies_parsed_at":"2024-01-03T02:02:14.137Z","dependency_job_id":null,"html_url":"https://github.com/ip2location/ip2location-cakephp","commit_stats":{"total_commits":20,"total_committers":2,"mean_commits":10.0,"dds":"0.050000000000000044","last_synced_commit":"061f60771c943154f8d343c8da1cfc0dba6f9cc2"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-cakephp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-cakephp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-cakephp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ip2location%2Fip2location-cakephp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ip2location","download_url":"https://codeload.github.com/ip2location/ip2location-cakephp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252654873,"owners_count":21783369,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cakephp","geolocation","ip-address-database","ip-database","ip-geolocation","ip-lookup","ip2location","ip2location-bin-databases","ip2location-cakephp"],"created_at":"2024-11-29T04:19:47.783Z","updated_at":"2025-05-07T04:07:49.346Z","avatar_url":"https://github.com/ip2location.png","language":"PHP","readme":"# IP2Location CakePHP Plugin\n[![Latest Stable Version](https://img.shields.io/packagist/v/ip2location/ip2location-cakephp.svg)](https://packagist.org/packages/ip2location/ip2location-cakephp)\n[![Total Downloads](https://img.shields.io/packagist/dt/ip2location/ip2location-cakephp.svg?style=flat-square)](https://packagist.org/packages/ip2location/ip2location-cakephp)\n\nIP2Location CakePHP plugin enables the user to find the country, region, district, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation and usage type, IP address type, IAB advertising category and ASN from IP address using IP2Location database. It has been optimized for speed and memory utilization. Developers can use the API to query all IP2Location BIN databases or web service for applications written using CakePHP.\n\nNote: This plugin works in CakePHP 4 and CakePHP 5.\n\n\n## INSTALLATION\n1. Run the command: `composer require ip2location/ip2location-cakephp` to download the plugin into the CakePHP platform.\n2. Download latest IP2Location BIN database\n    - IP2Location free LITE database at https://lite.ip2location.com\n    - IP2Location commercial database at https://www.ip2location.com\n3. Unzip and copy the BIN file into */vendor/ip2location/ip2location-cakephp/src/Data* folder.\n4. Rename the BIN file to IP2LOCATION.BIN.\n\n**Note:** The plugin has included an old BIN database for your testing and development purpose.\nYou may want to download a latest copy of BIN database as the URL stated above.\nThe BIN database refers to the binary file ended with .BIN extension, but not the CSV format.\nPlease select the right package for download.\n\n\n## USAGE\nIn this tutorial, we will show you on how to create a **TestsController** to display the IP information.\n\n1. Create a **TestsController** in CakePHP using the below command line\n```\nphp bin/cake bake controller Tests\n```\n2. Create a **Tests** folder in */cakephp/templates* if not exists.\n3. Create an empty **index.php** file in */cakephp/templates/Tests* folder.\n4. Open the **cakephp/src/Controller/TestsController.php** in any text editor.\n5. Remove the contents in TestsController.php and add the below lines into the controller file.\n\nNote: You just need to load the IP2Location library with **use IP2LocationCakePHP\\Controller\\IP2LocationCoresController** to use the functions.\n```\n\u003c?php\nnamespace App\\Controller;\n\nuse App\\Controller\\AppController;\nuse IP2LocationCakePHP\\Controller\\IP2LocationCoresController;\n\n// (required) Define IP2Location.io API key.\ndefine('IP2LOCATION_IO_API_KEY', 'your_api_key');\n\n// (optional) Define Translation information. Refer to https://www.ip2location.io/ip2location-documentation for available languages.\ndefine('IP2LOCATION_IO_LANGUAGE', 'en');\n\n/**\n * Tests Controller\n */\nclass TestsController extends AppController\n{\n\n    /**\n     * Index method\n     *\n     * @return \\Cake\\Http\\Response|void\n     */\n    public function index()\n    {\n        $IP2Location = new IP2LocationCoresController();\n\n        $record = $IP2Location-\u003eget('8.8.8.8');\n        echo 'Result from BIN Database:\u003cbr\u003e';\n        echo 'IP Address: ' . $record['ipAddress'] . '\u003cbr\u003e';\n        echo 'IP Number: ' . $record['ipNumber'] . '\u003cbr\u003e';\n        echo 'ISO Country Code: ' . $record['countryCode'] . '\u003cbr\u003e';\n        echo 'Country Name: ' . $record['countryName'] . '\u003cbr\u003e';\n        echo 'Region Name: ' . $record['regionName'] . '\u003cbr\u003e';\n        echo 'City Name: ' . $record['cityName'] . '\u003cbr\u003e';\n        echo 'Latitude: ' . $record['latitude'] . '\u003cbr\u003e';\n        echo 'Longitude: ' . $record['longitude'] . '\u003cbr\u003e';\n        echo 'ZIP Code: ' . $record['zipCode'] . '\u003cbr\u003e';\n        echo 'Time Zone: ' . $record['timeZone'] . '\u003cbr\u003e';\n        echo 'ISP Name: ' . $record['isp'] . '\u003cbr\u003e';\n        echo 'Domain Name: ' . $record['domainName'] . '\u003cbr\u003e';\n        echo 'Net Speed: ' . $record['netSpeed'] . '\u003cbr\u003e';\n        echo 'IDD Code: ' . $record['iddCode'] . '\u003cbr\u003e';\n        echo 'Area Code: ' . $record['areaCode'] . '\u003cbr\u003e';\n        echo 'Weather Station Code: ' . $record['weatherStationCode'] . '\u003cbr\u003e';\n        echo 'Weather Station Name: ' . $record['weatherStationName'] . '\u003cbr\u003e';\n        echo 'MCC: ' . $record['mcc'] . '\u003cbr\u003e';\n        echo 'MNC: ' . $record['mnc'] . '\u003cbr\u003e';\n        echo 'Mobile Carrier Name: ' . $record['mobileCarrierName'] . '\u003cbr\u003e';\n        echo 'Elevation: ' . $record['elevation'] . '\u003cbr\u003e';\n        echo 'Usage Type: ' . $record['usageType'] . '\u003cbr\u003e';\n        echo 'Address Type: ' . $record['addressType'] . '\u003cbr\u003e';\n        echo 'Category: ' . $record['category'] . '\u003cbr\u003e';\n        echo 'District: ' . $record['district'] . '\u003cbr\u003e';\n        echo 'ASN: ' . $record['asn'] . '\u003cbr\u003e';\n        echo 'AS: ' . $record['as'] . '\u003cbr\u003e';\n\n        $record = $IP2Location-\u003egetWebService('8.8.8.8');\n        echo 'Result from Web service:\u003cbr\u003e';\n        echo '\u003cpre\u003e';\n        print_r ($record);\n        echo '\u003c/pre\u003e';\n\n        var_dump($IP2Location-\u003eisIpv4('8.8.8.8'));echo '\u003cbr\u003e';\n        var_dump($IP2Location-\u003eisIpv6('2001:4860:4860::8888'));echo '\u003cbr\u003e';\n        print_r($IP2Location-\u003eipv4ToDecimal('8.8.8.8'));echo '\u003cbr\u003e';\n        print_r($IP2Location-\u003edecimalToIpv4(134744072));echo '\u003cbr\u003e';\n        print_r($IP2Location-\u003eipv6ToDecimal('2001:4860:4860::8888'));echo '\u003cbr\u003e';\n        print_r($IP2Location-\u003edecimalToIpv6('42541956123769884636017138956568135816'));echo '\u003cbr\u003e';\n        print_r($IP2Location-\u003eipv4ToCidr('8.0.0.0', '8.255.255.255'));echo '\u003cbr\u003e';\n        print_r($IP2Location-\u003ecidrToIpv4('8.0.0.0/8'));echo '\u003cbr\u003e';\n        print_r($IP2Location-\u003eipv6ToCidr('2002:0000:0000:1234:abcd:ffff:c0a8:0000', '2002:0000:0000:1234:ffff:ffff:ffff:ffff'));echo '\u003cbr\u003e';\n        print_r($IP2Location-\u003ecidrToIpv6('2002::1234:abcd:ffff:c0a8:101/64'));echo '\u003cbr\u003e';\n        print_r($IP2Location-\u003ecompressIpv6('2002:0000:0000:1234:FFFF:FFFF:FFFF:FFFF'));echo '\u003cbr\u003e';\n        print_r($IP2Location-\u003eexpandIpv6('2002::1234:FFFF:FFFF:FFFF:FFFF'));echo '\u003cbr\u003e';\n    }\n\n}\n```\n5. Enter the URL \u003cyour domain\u003e/Tests and run. You should see the information of **8.8.8.8** IP address.\n\n\n## DEPENDENCIES\nThis library requires IP2Location BIN data file or IP2Location API key to function. You may download the BIN data file at\n* IP2Location LITE BIN Data (Free): https://lite.ip2location.com\n* IP2Location Commercial BIN Data (Comprehensive): https://www.ip2location.com\n\nYou can also sign up for [IP2Location.io IP Geolocation API](https://www.ip2location.io/sign-up) to get one free API key.\n\n\n## IPv4 BIN vs IPv6 BIN\nUse the IPv4 BIN file if you just need to query IPv4 addresses.\n\nUse the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.\n\n\n## SUPPORT\nEmail: support@ip2location.com\n\nWebsite: https://www.ip2location.com\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-cakephp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fip2location%2Fip2location-cakephp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fip2location%2Fip2location-cakephp/lists"}