dsam70528 2016-11-17 02:49
浏览 48

Laravel 5.3作业无法读取公共文件

I have the following problem.

When I call getCountry from a Controller it works perfect but when I call it from a job I'm getting this error

The file \"assets/geoip/GeoIP2-City.mmdb\" does not exist or is not readable. at /home/vagrant/proyectos/ghc-l5/vendor/maxmind-db/reader/src/MaxMind/Db/Reader.php:46

I don't know why it works in Controllers but not in Jobs. Any idea?

<?php

namespace App\Helpers;

use GeoIp2\Database\Reader;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Log;

class SiteHelper {

    public static function getCountry($ip)
    {
        try
        {
            $reader = new Reader('assets/geoip/GeoIP2-City.mmdb');
            $record = $reader->city($ip);
            return $record->country->isoCode;
        }
        catch(\Exception $e)
        {
            Log::error("SiteHelper -> getCountry -> ERROR al detectar IP", ['ip' => $ip, 'exception' => $e]);
            throw $e;
        }
    }

}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 FPGA-SRIO初始化失败
    • ¥15 MapReduce实现倒排索引失败
    • ¥15 luckysheet
    • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
    • ¥15 找一位技术过硬的游戏pj程序员
    • ¥15 matlab生成电测深三层曲线模型代码
    • ¥50 随机森林与房贷信用风险模型
    • ¥50 buildozer打包kivy app失败
    • ¥30 在vs2022里运行python代码
    • ¥15 不同尺寸货物如何寻找合适的包装箱型谱