我是使用作曲家包的新手。我已经得到了一些工作,但我遇到了一个我想使用的谷歌地图包,但我无法让它正确加载。
php-google-maps 包
我使用该软件包的尝试:
<?php
require './vendor/autoload.php';
use PHPGoogleMapsServiceGeocoder;
use PHPGoogleMapsServiceGeocodeError;
use PHPGoogleMapsServiceGeocodeResult;
use PHPGoogleMapsServiceGeocodeException;
$map = new PHPGoogleMapsMap;
// Rest of GMap code goes here...
?>
此操作失败,并显示消息Class 'PHPGoogleMapsMap' not found
作曲家.json 文件:
{
"require" : {
"nategood/httpful":"*",
"nesbot/carbon": "dev-master",
"php-google-maps/php-google-maps": "dev-master"
}
}
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"
}
}
]
}