承接 yamilovs/sypex-geo-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yamilovs/sypex-geo-bundle

最新稳定版本:2.0.1

Composer 安装命令:

composer require yamilovs/sypex-geo-bundle

包简介

An adaptation of SypexGeo library to Symfony Bundle system

README 文档

README

Build Status

SypexGeoBundle

This is an adaptation of Sypex Geo Library for Symfony.

Installation

Step 1: Download SypexGeoBundle using composer

Add SypexGeoBundle by running the command:

$ composer require yamilovs/sypex-geo-bundle:^2.0

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Yamilovs\Bundle\SypexGeoBundle\SypexGeoBundle(),
    );
}

Step 3: Add some configurations

# app/config/config.yml

yamilovs_sypex_geo:
    mode: FILE # FILE (default) | BATCH | MEMORY
    database_path: "%kernel.root_dir%/../var/SypexGeoDatabase/SxGeoCity.dat"

If you need the proxy configuration for database update, you can add:

yamilovs_sypex_geo:
    ......
    connection:
        proxy:
            host: 'xxx.xxx.xxx.xxx'
            port: # port number
            
            # You can enable user credentials if you have them
            auth:
                user: 'your username'
                password: 'your password'

Step 4: Download necessary databases

Download necessary databases to database_path.

  • You can run php bin/console yamilovs:sypex-geo:update-database-file
  • Or download it manually from Sypex Geo City

Usage

In your controller

<?php
// src/Controller/FooController.php
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Yamilovs\SypexGeo\SypexGeo;

class FooController extends Controller
{
    public function fooAction(Request $request, SypexGeo $sypexGeo)
    {
        $userIp = $request->getClientIp();
        $testIp = '88.86.218.24';

        $city = $sypexGeo->getCity($testIp, true);

        dump($city);
    }
}

Note:

Your local ip address is 127.0.0.1 and Sypex Geo cant get your city or country!

If you want to check data from specific IP address

You can run php bin/console yamilovs:sypex-geo:get-ip-data aa.bb.cc.dd

统计信息

  • 总下载量: 44.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-15