0

我是使用作曲家包的新手。我已经完成了一些工作,但我遇到了一个我想使用的 Google 地图包,但我无法正确加载它。

php-google-maps 包

我尝试使用该软件包:

<?php

require './vendor/autoload.php';

use \PHPGoogleMaps\Service\Geocoder;
use \PHPGoogleMaps\Service\GeocodeError;
use \PHPGoogleMaps\Service\GeocodeResult;
use \PHPGoogleMaps\Service\GeocodeException;

$map = new \PHPGoogleMaps\Map;
// Rest of GMap code goes here...
?>

这失败并显示消息Class 'PHPGoogleMaps\Map' not found

作曲家.json 文件:

{
    "require" : {
        "nategood/httpful":"*",
        "nesbot/carbon": "dev-master",
        "php-google-maps/php-google-maps": "dev-master"
    }
}
4

1 回答 1

1

PHPGoogleMaps 包的 composer.json 中有一个错误。安装后的目录结构不符合 PSR-0 自动加载标准。

我提交了修复问题的PR,但在修复之前,您可以为包定义自己的存储库(更改目标目录):

{
    "require" : {
        "nategood/httpful":"*",
        "nesbot/carbon": "dev-master",
        "jakzal/php-google-maps": "dev-master"
    },
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "jakzal/php-google-maps",
                "version": "dev-master",
                "source": {
                    "url": "https://github.com/galen/PHPGoogleMaps",
                    "type": "git",
                    "reference": "master"
                },
                "autoload": {
                    "psr-0": {"PHPGoogleMaps": ""}
                },
                "target-dir": "PHPGoogleMaps"
            }
        }
    ]
}
于 2012-10-14T09:49:54.807 回答