未找到“Geocoder \ Provider \ GoogleMapsProvider”类

时间:2017-07-11 12:42:26

标签: php zend-framework2

我正在尝试运行一些遗留应用程序但是我遇到了一个依赖于地理编码器的墙。

我收到了消息:Fatal error: Class Geocoder\Provider\GoogleMapsProvider' not found

我的源代码显示标记行的错误:

<?php

namespace Application\Geocoder\Provider;

use Geocoder\Exception\NoResultException;
use Geocoder\Exception\QuotaExceededException;
use Geocoder\Exception\UnsupportedException;
use Geocoder\Exception\InvalidCredentialsException;
use Geocoder\HttpAdapter\HttpAdapterInterface;
use Geocoder\Provider\GoogleMapsProvider as ExtendGoogleMapsProvider;

class GoogleMapsProvider extends ExtendGoogleMapsProvider
{ <===== The error line is HERE

我安装了willdurand/geocoder依赖项:

  "require" : {
    "doctrine/doctrine-orm-module" : "0.7.0",
    "php" : ">=5.3.3",
    "gedmo/doctrine-extensions" : "2.3.8",
    "bjyoungblood/bjy-authorize" : "1.4.0",
    "doctrine/common" : "2.3.0",
    "twbs/bootstrap" : "2.3.2",
    "zf-commons/zfc-user" : "0.1.x-dev",
    "zf-commons/zfc-user-doctrine-orm" : "master-dev",
    "mwillbanks/zfc-twitter-bootstrap" : "master-dev",
    "zendframework/zendframework" : "2.2.5",
        "willdurand/geocoder": "^3.3",
    "firebase/php-jwt": "^4.0"
  },

diagnose命令说:

$ php composer.phar diagnose
Checking composer.json: FAIL
name : invalid value (Extrapack), must match [A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
require.gedmo/doctrine-extensions : exact version constraints (2.3.8) should be avoided if the package follows semantic versioning
require.bjyoungblood/bjy-authorize : exact version constraints (1.4.0) should be avoided if the package follows semantic versioning
require.doctrine/common : exact version constraints (2.3.0) should be avoided if the package follows semantic versioning
require.twbs/bootstrap : exact version constraints (2.3.2) should be avoided if the package follows semantic versioning
require.zf-commons/zfc-user-doctrine-orm : unbound version constraints (master-dev) should be avoided
require.mwillbanks/zfc-twitter-bootstrap : unbound version constraints (master-dev) should be avoided
require.zendframework/zendframework : exact version constraints (2.2.5) should be avoided if the package follows semantic versioning
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK

我的phar模块:

Phar: PHP Archive support   enabled
Phar EXT version    2.0.2
Phar API version    1.1.1
SVN revision    $Id: 780be432570e80dd34c1a9c217ef87ade22bf136 $
Phar-based phar archives    enabled
Tar-based phar archives enabled
ZIP-based phar archives enabled
gzip compression    enabled
bzip2 compression   enabled
Native OpenSSL support  enabled

在源代码中困扰我的事情是使用

use Geocoder\Provider\GoogleMapsProvider as ExtendGoogleMapsProvider;

表示该类扩展自身。这对我来说毫无意义。

1 个答案:

答案 0 :(得分:1)

如果您查看source,则类Geocoder\Provider\GoogleMapsProvider不存在。

这可能表示您使用的是比旧版项目更新的版本。

查看changelog确认已在Provider行中删除3.x后缀。

首先,您可能想要使用旧版本。运行

$ composer require willdurand/geocoder:^2.8.2

或者,尝试使用3.x行没有后缀的重命名的提供者:

use Geocoder\Provider\GoogleMaps;

class GoogleMapsProvider extends GoogleMaps
{
    // ...
}

注意使用

为类名设置别名
use Geocoder\Provider\GoogleMapsProvider as ExtendGoogleMapsProvider;

防止碰撞。

供参考,见: