sparkeleven / abn-lookup
1.0.0
2020-12-22 01:16 UTC
Requires
- php: ^7.2|^8.0
- ext-dom: *
- ext-json: *
- ext-soap: *
- ext-xml: *
- illuminate/http: ^5|^6|^7|^8|^9
- illuminate/support: ^5|^6|^7|^8|^9
Requires (Dev)
- orchestra/testbench: ^7.0
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2024-09-26 01:53:33 UTC
README
sparkeleven/abn-lookup
是一个用于轻松访问 ABN Lookup SOAP API 集的 Composer 包。支持 Laravel ^5|^6|^7|^8
以及纯 PHP/Composer 项目。
安装
1. 将包下载到您的项目中
要将此库添加到您的 Laravel 项目中,您可以在 Laravel 项目的当前工作目录中运行以下命令。
composer require sparkeleven/abn-lookup
2. 设置服务提供者和别名
对于早于 5.5 版本的 Laravel(不提供包自动发现),您应该在您的 config/app.php
文件中添加以下内容;
// Under `providers` array
SparkEleven\AbnLookup\AbnLookupServiceProvider::class,
// Under `aliases` array
'AbnLookup' => SparkEleven\AbnLookup\Facades\AbnLookup::class,
3. 将包发布到您的项目中
运行以下命令以发布包(配置、翻译、视图)
php artisan vendor:publish --provider=SparkEleven\\AbnLookup\\AbnLookupServiceProvider
配置
成功发布包后,您应该检查 config/abn-lookup.php
文件。阅读此文件上的指南以设置必要的信息(认证 GUID 等)。
<?php
return [
/*
|--------------------------------------------------------------------------
| Authentication GUID
|--------------------------------------------------------------------------
|
| To access ABN Lookup web services, an authentication GUID (Globally
| Unique Identifier) is required. You can find your own GUID from the
| email received after your registration is completed.
|
| For more details, visit below link;
| https://abr.business.gov.au/Tools/WebServices#registration
|
*/
'auth_guid' => env('ABNLOOKUP_AUTH_GUID'),
/*
|--------------------------------------------------------------------------
| WSDL path
|--------------------------------------------------------------------------
|
| Path to WSDL which describes the web services of ABN Lookup. It is
| recommended not to change this value from default.
|
| For more details, visit below link;
| https://abr.business.gov.au/Tools/WebServices#wsdl
|
*/
'wsdl' => \SparkEleven\AbnLookup\Services\AbnLookupService::DEFAULT_WSDL,
/*
|--------------------------------------------------------------------------
| WSDL cache method
|--------------------------------------------------------------------------
|
| For better performance, it is recommended to cache the WSDL file. Do not
| change this value if you are not sure about it, or you will experience
| terrible response time.
|
| Must be one of;
| * WSDL_CACHE_NONE
| * WSDL_CACHE_DISK
| * WSDL_CACHE_MEMORY
| * WSDL_CACHE_BOTH
|
| For more details, visit below link;
| https://php.ac.cn/manual/en/soapclient.soapclient.php
|
*/
'wsdl_cache' => env('ABNLOOKUP_WSDL_CACHE', WSDL_CACHE_DISK),
];
如何使用
您可以直接导入 AbnLookup
门面来访问提供的静态搜索方法。
示例
use AbnLookup;
// searchByAbn
$result = AbnLookup::searchByAbn('33102417032');
echo $result['mainName']['organisationName']; // Google Australia Pty Ltd
// searchByAsic
$result = AbnLookup::searchByAsic('102417032');
echo $result['entityType']['entityDescription']; // Australian Private Company
echo $result['mainName']['organisationName']; // Google Australia Pty Ltd
// searchByName
$result = AbnLookup::searchByName('Google Australia Pty Ltd');
echo $result['searchResultsRecord'][0]['ABN']['identifierValue']; // 41726564339
您可以在 WSDL 文档 中检查正确的 i/o 架构。
Laravel 之外
此包也可以在 Laravel 项目之外使用。运行以下代码片段以初始化服务类并使用与 Laravel 项目相同的代码。
use SparkEleven\AbnLookup\Services\AbnLookupService as AbnLookup;
// Initiate service
AbnLookup::reset(
'00000000-0000-0000-0000-000000000000', // Your authentication GUID
AbnLookup::DEFAULT_WSDL, // WSDL path
WSDL_CACHE_DISK, // WSDL cache method
);
许可证
sparkeleven/abn-lookup
是在 MIT 许可证条款下分发的免费软件。
贡献指南
支持 PSR-1 和 PSR-4 PHP 编码标准以及语义版本。
请在问题页面报告您发现的任何问题。欢迎拉取请求。