2017-02-22 8 views
0

自分のプロジェクト(Drupalではない)のために役に立つと思われる特定のアドレス書式のコンポーザープラグインがcommerceguys/addressinghttps://www.versioneye.com/php/commerceguys:addressing/0.8.4)です。Drupal以外のサイトにDrupalコンポーザーパッケージを設定する

私は作曲家に慣れていましたが、私はプロジェクトでそれを必要としましたが、私が使用している他の作曲家パッケージのように機能していないようです。私はこれがDrupalとは何か特別な関係があるのか​​どうかはわかりませんが、DrupalのReadmeには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); 

を使用しています。しかし、これは私にこのエラーを与えている

Fatal error: Uncaught Error: Class 'CommerceGuys\Addressing\AddressFormat\AddressFormatRepository' not found in /media/sf_domains/coolproject.com/public_html/coolfile.php on line 8

インストール、すべての「commerceguys」ファイルに問題があるように思えません。 「vendor」フォルダ内の正しい場所にあります。私は〜6何か問題がなくても作曲家を通してインストールされています。私は何が欠けていますか?

答えて

0

実際には、 "use"節については、ドキュメントが単なるプレーンテキストではないようです。ファイルそのものを手動で検索した後、私は実際には現在大きく働いています。

use CommerceGuys\Addressing\Model\Address; 
use CommerceGuys\Addressing\Formatter\DefaultFormatter; 
use CommerceGuys\Addressing\Repository\AddressFormatRepository; 
use CommerceGuys\Addressing\Repository\CountryRepository; 
use CommerceGuys\Addressing\Repository\SubdivisionRepository; 

関連する問題