itk-dev / serviceplatformen
1.5.2
2024-08-06 14:04 UTC
Requires
- php: ^8.1
- composer-runtime-api: ^2.2
- ext-curl: *
- ext-dom: *
- ext-json: *
- ext-openssl: *
- ext-simplexml: *
- ext-soap: *
- goetas-webservices/xsd2php-runtime: ^0.2.16
- http-interop/http-factory-guzzle: ^1.2
- itk-dev/azure-key-vault-php: ^1.0
- jms/serializer: ^3.18
- php-http/guzzle7-adapter: ^1.0
- symfony/cache: ^5.4 || ^6.0
- symfony/http-client: ^5.4 || ^6.0
- symfony/options-resolver: ^5.4 || ^6.0
- symfony/property-access: ^4.4 || ^5.4 || ^6.0
- symfony/string: ^5.4 || ^6.0
- symfony/uid: ^5.4 || ^6.0
- wsdltophp/packagebase: ^5.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.11
- goetas-webservices/xsd2php: dev-feature-xml-namespace-prefix
- phan/phan: ^5.4
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.7
- symfony/console: ^5.4 || ^6.0
- symfony/mime: ^5.4 || ^6.0
- wsdltophp/packagegenerator: ^4.1
This package is auto-updated.
Last update: 2024-09-24 14:18:46 UTC
README
用于与Serviceplatformen上的服务交互的库。
支持的服务
- CPR replika opslag (SF1520_3.6): https://digitaliseringskataloget.dk/integration/sf1520?version=3.6
- CVR-Online (SF1530_2.4): https://digitaliseringskataloget.dk/integration/sf1530
- 部分来自Afsend post (SF1601): https://digitaliseringskataloget.dk/integration/sf1601. 更多详细信息请见SF1601: Afsend post.
更新资源和类
我们使用WsdlToPhp/PackageGenerator生成与SOAP服务通信的PHP类。要更新资源和生成的类,运行
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer install # Update WSDL resources. docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest bin/generate resources # Generate PHP classes from WSDL resources. docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest bin/generate classes
测试命令
docker run --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest vendor/bin/serviceplatformen-sf1601-kombipostafsend --help
在开发此库时,使用bin/serviceplatformen-sf1601-kombipostafsend
(与bin/SF1601/kombipostafsend
建立符号链接)。例如:
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest bin/serviceplatformen-sf1601-kombipostafsend
docker run --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest vendor/bin/serviceplatformen-sf1601-postforespoerg --help
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest bin/serviceplatformen-sf1601-postforespoerg
入门
以下说明将帮助您在本地机器上复制项目副本并运行,以便进行开发和测试。有关如何在实际系统上部署项目的说明,请参阅部署部分。
先决条件
- Git 2.25或更高版本。
- PHP 7.3或更高版本。
- Composer 1.9或更高版本。
安装
克隆存储库
git clone https://github.com/itk-dev/serviceplatformen
安装依赖项
cd serviceplatformen
composer install
运行测试
单元测试
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer tests/unit
端到端测试
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer tests/end-to-end
以及编码风格测试
PHP_CodeSniffer
composer coding-standards-check/phpcs
PHP-CS-Fixer
composer coding-standards-check/php-cs-fixer
静态代码分析
Phan
composer static-code-analysis/phan
部署
composer require itk-dev/serviceplatformen
用法
存储在本地文件系统中的证书
<?php require_once 'vendor/autoload.php'; use ItkDev\Serviceplatformen\Certificate\FilesystemCertificateLocator; use ItkDev\Serviceplatformen\Request\InvocationContextRequestGenerator; use ItkDev\Serviceplatformen\Service\PersonBaseDataExtendedService; $certificateLocator = new FilesystemCertificateLocator(__DIR__.'path_to_certificate.pem', 'passphrase if any'); $pathToWsdl = __DIR__.'/resources/person-base-data-extended-service-contract/wsdl/context/PersonBaseDataExtendedService.wsdl'; $options = [ 'local_cert' => $certificateLocator->getAbsolutePathToCertificate(), 'passphrase' => $certificateLocator->getPassphrase(), 'location' => 'https://url.to.service.endpoint' ]; $soapClient = new SoapClient($pathToWsdl, $options); $requestGenerator = new InvocationContextRequestGenerator( 'xxxx', // Service agreement UUID 'xxxx', // User system UUID 'xxxx', // Service UUID 'xxxx' // User UUID ); $service = new PersonBaseDataExtendedService($soapClient, $requestGenerator); $response = $service->personLookup('1234567891'); var_dump($response);
存储在Azure Key Vault中的证书
有关在Azure Key Vault中存储证书的详细信息,请参阅存储证书。
<?php require_once 'vendor/autoload.php'; use ItkDev\AzureKeyVault\Authorisation\VaultToken; use ItkDev\AzureKeyVault\KeyVault\VaultSecret; use ItkDev\Serviceplatformen\Certificate\AzureKeyVaultCertificateLocator; use ItkDev\Serviceplatformen\Request\InvocationContextRequestGenerator; use ItkDev\Serviceplatformen\Service\PersonBaseDataExtendedService; $vaultToken = new VaultToken( $httpClient, // PSR-18 compatible http client $requestFactory // PSR-17 compatible request factory ); $token = $vaultToken->getToken( 'xxxx', // Azure tenant id 'xxxx', // Client id (azure application id) 'xxxx' // Client secret ); $vault = new VaultSecret( $httpClient, // PSR-18 compatible http client $requestFactory, // PSR-17 compatible request factory 'testVault', // Name of vault $token->getAccessToken() ); $certificateLocator = new AzureKeyVaultCertificateLocator( $vault, 'xxxx', // Name of the certificate 'xxxx', // Version of the certificate 'yyyy' // optional passphrase for the certificate ); $pathToWsdl = __DIR__.'/resources/person-base-data-extended-service-contract/wsdl/context/PersonBaseDataExtendedService.wsdl'; $options = [ 'local_cert' => $certificateLocator->getAbsolutePathToCertificate(), 'passphrase' => $certificateLocator->getPassphrase(), 'location' => 'https://url.to.service.endpoint' ]; $soapClient = new SoapClient($pathToWsdl, $options); $requestGenerator = new InvocationContextRequestGenerator( 'xxxx', // Service agreement UUID 'xxxx', // User system UUID 'xxxx', // Service UUID 'xxxx' // User UUID ); $service = new PersonBaseDataExtendedService($soapClient, $requestGenerator); $response = $service->personLookup('1234567891'); var_dump($response);
贡献
拉取请求流程
在创建拉取请求之前,请确保您已经考虑了以下内容
- 更新README.md,包括相关更改的详细信息。
- 更新CHANGELOG.md,包括新功能/更改/错误修复等。
一旦您获得另一位开发者的批准,或者如果您没有权限这样做,您可以要求审阅者为您合并。
编码标准
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer install docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-apply docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-check
docker run --rm --volume ${PWD}:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md' --fix docker run --rm --volume ${PWD}:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md'
代码分析
docker run --interactive --tty --rm --volume ${PWD}:/app --env COMPOSER_MEMORY_LIMIT=-1 itkdev/php8.1-fpm:latest composer code-analysis
版本控制
我们使用SemVer进行版本控制。有关可用版本,请参阅此存储库的标签。
许可
本项目采用MIT许可协议 - 有关详细信息,请参阅LICENSE.md文件。