2013-12-12 4 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 \ 데이터베이스 \ 리더;

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

에서 해당의 Phar 파일을 툭