ibericode/vat-bundle
最新稳定版本:2.2.1
Composer 安装命令:
composer require ibericode/vat-bundle
包简介
Bundle for using ibericode/vat in a Symfony environment
关键字:
README 文档
README
This bundle allows you to use ibericode/vat in your Symfony projects.
- Fetch VAT rates for any European member state from ibericode/vat-rates
- Validate VAT numbers (by format and existence)
- Validate ISO-3316 alpha-2 country codes
- Determine whether a country is part of the EU
- Geo-locate IP addresses
The official VIES VAT number validation SOAP API is used for validating VAT numbers.
Installation
First, install the bundle using Composer.
composer require ibericode/vat-bundle
Then, load the bundle by adding it to your config/bundles.php file.
Ibericode\Vat\Bundle\VatBundle::class => ['all' => true]
Usage
Check out ibericode/vat for direct usage examples. This bundle adds service configuration & a validation constraint for VAT numbers.
Dependency injection
With this bundle enabled, you can use dependency injection to retrieve a class instance for the Countries, Validator, Rates or Geolocator classes.
use Ibericode\Vat\Countries; use Ibericode\Vat\Validator; use Ibericode\Vat\Rates; use Ibericode\Vat\Geolocator; class MyController { /** * Type-hint the class on your service constructors to retrieve a class instance */ public function __construct( Rates $rates, Validator $validator, Countries $countries, Geolocator $geolocator ) { $rates->getRateForCountry('NL'); // 21.00 $validator->validateVatNumber('NL123456789B01'); // false $countries->isCountryCodeInEU('US') // false $geolocator->locateIpAddress('8.8.8.8'); // US } }
Validation
To validate a VAT number using Symfony's Validation component, you can use the VatNumber constraint.
use Ibericode\Vat\Bundle\Validator\Constraints\VatNumber; class Customer { /** * @VatNumber() */ public $vatNumber; }
License
MIT licensed. See the LICENSE file for details.
统计信息
- 总下载量: 235.58k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 21
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 3
其他信息
- 授权协议: MIT
- 更新时间: 2019-02-07