【发布时间】:2017-02-22 17:32:14
【问题描述】:
有一个特殊的地址格式化作曲家插件,它看起来对我自己的项目(不是 Drupal)非常有用,名为 commerceguys/addressing (https://www.versioneye.com/php/commerceguys:addressing/0.8.4)。
所以我习惯了作曲家,我只是在我的项目中需要它,但它似乎不像我正在使用的所有其他作曲家包那样运作。我不确定这是否与 Drupal 有特别的关系,我只提到这是因为他们的自述文件提到这是一个 Drupal 模块(但因为它可以通过作曲家获得,我认为它可能会起作用)。根据他们的文档,我正在使用以下代码
use CommerceGuys\Addressing\Address;
use CommerceGuys\Addressing\Formatter\PostalLabelFormatter;
use CommerceGuys\Addressing\AddressFormat\AddressFormatRepository;
use CommerceGuys\Addressing\Repository\CountryRepository;
use CommerceGuys\Addressing\Subdivision\SubdivisionRepository;
$addressFormatRepository = new AddressFormatRepository();
$countryRepository = new CountryRepository();
$subdivisionRepository = new SubdivisionRepository();
// Defaults to text rendering. Requires setting the origin country code
// (e.g. 'FR') through the constructor or the setter, before calling format().
$formatter = new PostalLabelFormatter($addressFormatRepository, $countryRepository, $subdivisionRepository, 'FR', 'fr');
$address = new Address();
$address = $address
->withCountryCode('US')
->withAdministrativeArea('CA')
->withLocality('Mountain View')
->withAddressLine1('1098 Alta Ave');
echo $formatter->format($address);
但这给了我这个错误
致命错误:未捕获的错误:在第 8 行的 /media/sf_domains/coolproject.com/public_html/coolfile.php 中找不到类“CommerceGuys\Addressing\AddressFormat\AddressFormatRepository”
安装似乎没有任何问题,所有“commerceguys”文件都位于“vendor”文件夹中的正确位置。我确实通过作曲家安装了大约 6 个其他东西,这些东西可以正常工作。我错过了什么?
【问题讨论】:
标签: php drupal composer-php