blackknight467 / smarty-streets-bundle
SmartyStreet API 的 Symfony 2 扩展包
v1.0.1
2016-01-22 10:24 UTC
Requires
- php: >=5.4
Requires (Dev)
- symfony/framework-bundle: >=2.3
This package is not auto-updated.
Last update: 2024-09-22 07:12:44 UTC
README
SmartyStreets 扩展包用于 Symfony 2。
安装
步骤 1: 下载 SmartyStreetsBundle
使用 Composer
将以下内容添加到您的 composer.json 文件的 "require" 部分
"blackknight467/smarty-streets-bundle": "1.*"
步骤 2: 启用扩展包
在 Kernel 中启用扩展包
<?php // app/appKernel.php public function registerBundles() { $bundles = array( // ... new blackknight467\SmartyStreetsBundle\SmartyStreetsBundle(), ); }
步骤 3: 配置扩展包
将以下配置添加到您的 app/config/config.yml
smarty_streets:
auth_id: 'your SmartyStreets auth id'
auth_token: 'your SmartyStreets auth token'
使用方法
您可以使用两种方式使用此扩展包。第一种是使用提供的接口映射到您现有的实体。
第二种是直接传递文本字符串给使用它们的函数。
使用文本字符串
在控制器中
$this->get('blackknight467.smarty_streets')->verifyUSStreetAddressText('1600 Pennsylvania Ave NW, Washington, DC 20500');
使用接口
在实体中
class SampleAddressEntity implements SimpleSmartyStreetsUSAddressInterface
在控制器中
$address = new SampleAddressEntity();
$this->get('blackknight467.smarty_streets')->verifyUSStreetAddress($address);
命令
此扩展包包含一些 symfony 控制台命令,以便您测试文本输入
php app/console smartystreets:us-verify {address}
php app/console smartystreets:us-zip-verify {zipcode}
许可证
此扩展包采用 MIT 许可证。请参阅包中的完整许可证:LICENSE