2013-12-12 43 views
0

我正在嘗試安裝Maxmind的GeoIP2。我做的一切都是由他們的指示,我仍然得到這個惱人的錯誤:在GeoIP2中找不到的閱讀器類

Fatal error: Class 'GeoIp2\Database\reader' not found in C:\Program Files\*\*\localweb\GeoIp2\index.php on line 19 

這是劇本的樣子裏面的index.php:

<?php 
require_once 'vendor/autoload.php'; 
use GeoIp2\Database\reader; 
// This creates the Reader object, which should be reused across 
// lookups. 
$reader = new Reader('C:/Program Files/*/*/localweb/GeoIp2/Database/GeoLite2-Country.mmdb'); 
$record = $reader->country('128.101.101.101'); 
?> 

任何人都可以幫助嗎?

回答

1

嘗試更改:

使用GeoIp2 \ Database \ reader;

至:

使用GeoIp2 \ Database \ Reader;

0

這對我感謝@Greg Oschwald! 由於我使用的不是作曲家,我的代碼現在是:

<?php 
require 'geoip2.phar'; 
try { 
    $reader = new GeoIp2\Database\Reader('GeoLite2-City.mmdb'); 
    $record = $reader->city('128.101.101.101'); 
    print($record->country->isoCode . "\n"); // 'US' 
    print($record->country->name . "\n"); // 'United States' 
    print($record->country->names['zh-CN'] . "\n"); // '??' 
    print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota' 
    print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN' 
    print($record->city->name . "\n"); // 'Minneapolis' 
    print($record->postal->code . "\n"); // '55455' 
    print($record->location->latitude . "\n"); // 44.9733 
    print($record->location->longitude . "\n"); // -93.2323 
} catch (Exception $e) { 
    echo 'Could not open Phar: ', $e; 
} 

接過那藥業文件從https://github.com/maxmind/GeoIP2-php/releases

相關問題