在非drupal网站中设置Drupal Composer软件包



有一个特定的地址格式化作曲家插件,看起来它对我自己的项目(而不是drupal)称为commerceguys/addressing(https://wwwww.versioneye.com/php/php/commerceguysguys)非常有用。:地址/0.8.4)。

所以我习惯了作曲家,我只是在项目中需要它,但是它似乎并没有像我使用的所有其他作曲家软件包那样运行。我不确定这是否与Drupal有关,我只提到这一点,因为他们的老板提到这是一个Drupal模块(但是由于作曲家可以通过作曲家提供,所以我认为这可能起作用)。根据他们的文档,我正在使用以下代码

use CommerceGuysAddressingAddress;
use CommerceGuysAddressingFormatterPostalLabelFormatter;
use CommerceGuysAddressingAddressFormatAddressFormatRepository;
use CommerceGuysAddressingRepositoryCountryRepository;
use CommerceGuysAddressingSubdivisionSubdivisionRepository;
$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);

,但这给了我这个错误

致命错误:未知的错误:类'Commerceguys dordsing addressformat addressFormatRepository'在/media/sf_domains/coolproject.com/public_html/coolfile.php上未找到8

安装似乎没有任何问题,所有"商业"文件都位于"供应商"文件夹中的正确位置。我确实有大约6个左右的其他内容,这些内容通过作曲家而没有任何问题。我想念什么?

实际上,当涉及"使用"条款时,它们的文档似乎是不正确的。在文件本身中手动搜索它们后,我想到了

use CommerceGuysAddressingModelAddress;
use CommerceGuysAddressingFormatterDefaultFormatter;
use CommerceGuysAddressingRepositoryAddressFormatRepository;
use CommerceGuysAddressingRepositoryCountryRepository;
use CommerceGuysAddressingRepositorySubdivisionRepository;

现在实际上运作良好。

最新更新