Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Library for interacting with services on [Serviceplatformen](https://www.service
* Parts of [Afsend post (SF1601):
https://digitaliseringskataloget.dk/integration/sf1601](https://digitaliseringskataloget.dk/integration/sf1601).
See [SF1601: Afsend post](docs/SF1601.md) for details.
* [Fordelingskomponenten (SF2900): https://digitaliseringskataloget.dk/integration/sf2900](https://digitaliseringskataloget.dk/integration/sf2900)

## Updating resources and classes

Expand All @@ -18,32 +19,28 @@ generate PHP classes for talking to SOAP services. To update
[resources](./resources) and [generated classes](./generated-classes), run

``` shell
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer install
# Update WSDL resources.
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest bin/generate resources
# Generate PHP classes from WSDL resources.
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest bin/generate classes
task generate
```

## Test commands

``` shell
docker run --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest vendor/bin/serviceplatformen-sf1601-kombipostafsend --help
docker compose run --rm phpfpm vendor/bin/serviceplatformen-sf1601-kombipostafsend --help
```

Use `bin/serviceplatformen-sf1601-kombipostafsend` (symlinked to
`bin/SF1601/kombipostafsend`) during development of this library. i.e.

``` shell
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest bin/serviceplatformen-sf1601-kombipostafsend
docker compose run --rm phpfpm bin/serviceplatformen-sf1601-kombipostafsend
```

``` shell
docker run --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest vendor/bin/serviceplatformen-sf1601-postforespoerg --help
docker compose run --rm phpfpm vendor/bin/serviceplatformen-sf1601-postforespoerg --help
```

``` shell
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest bin/serviceplatformen-sf1601-postforespoerg
docker compose run --rm phpfpm bin/serviceplatformen-sf1601-postforespoerg
```

## Getting Started
Expand Down Expand Up @@ -71,49 +68,49 @@ Install the dependencies:
``` shell
cd serviceplatformen

composer install
docker compose run --rm phpfpm composer install
```

## Running the tests

Unit tests:

``` shell
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer tests/unit
docker compose run --rm phpfpm composer tests/unit
```

End to end tests:

``` shell
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer tests/end-to-end
docker compose run --rm phpfpm composer tests/end-to-end
```

### And coding style tests

PHP_CodeSniffer

``` shell
composer coding-standards-check/phpcs
docker compose run --rm phpfpm composer coding-standards-check/phpcs
```

PHP-CS-Fixer

``` shell
composer coding-standards-check/php-cs-fixer
docker compose run --rm phpfpm composer coding-standards-check/php-cs-fixer
```

### Static code analysis

Phan

``` shell
composer static-code-analysis/phan
docker compose run --rm phpfpm composer static-code-analysis/phan
```

## Deployment

``` shell
composer require itk-dev/serviceplatformen
docker compose run --rm phpfpm composer require itk-dev/serviceplatformen
```

## Usage
Expand Down Expand Up @@ -237,20 +234,20 @@ reviewer to merge it for you.
### Coding standards

``` shell
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer install
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer coding-standards-apply
docker run --interactive --tty --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer coding-standards-check
docker compose run --rm phpfpm composer install
docker compose run --rm phpfpm composer coding-standards-apply
docker compose run --rm phpfpm composer coding-standards-check
```

``` shell
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 compose run --rm markdownlint markdownlint '**/*.md' --fix
docker compose run --rm markdownlint markdownlint '**/*.md'
```

### Code analysis

``` shell
docker run --interactive --tty --rm --volume ${PWD}:/app --env COMPOSER_MEMORY_LIMIT=-1 itkdev/php8.3-fpm:latest composer code-analysis
docker compose run --rm phpfpm composer code-analysis
```

## Versioning
Expand Down
58 changes: 58 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# https://taskfile.dev

version: "3"

tasks:
generate:
desc: Generate stuff …
cmds:
- task: compose
vars:
TASK_ARGS: run --rm phpfpm composer install
- task: compose
vars:
TASK_ARGS: run --rm phpfpm bin/generate resources
- task: compose
vars:
TASK_ARGS: run --rm phpfpm bin/generate classes

compose:
cmds:
- docker compose {{.TASK_ARGS}} {{.CLI_ARGS}}
internal: true

composer:
desc: Run composer inside docker compose setup, e.g. `task {{.TASK}} -- install`
cmds:
- task: compose
vars:
TASK_ARGS: run --rm phpfpm composer {{.TASK_ARGS}}

php:
# https://taskfile.dev/docs/reference/templating#task-1
desc: Run PHP inside docker compose setup, e.g. `task {{.TASK}} -- bin/serviceplatformen-sf2900-fordelingsobjekt-list`
cmds:
- task: compose
vars:
TASK_ARGS: run --rm phpfpm php

debug:php:
desc: Run PHP inside docker compose setup with Xdebug enabled, e.g. `task {{.TASK}} -- bin/serviceplatformen-sf2900-fordelingsobjekt-list`
cmds:
- task: compose
vars:
TASK_ARGS: run --env PHP_XDEBUG_MODE=debug --env PHP_XDEBUG_WITH_REQUEST=yes --rm phpfpm php

coding-standards:coding-standards:check:
cmds:
- task: composer
vars:
TASK_ARGS: coding-standards-apply
- task: composer
vars:
TASK_ARGS: coding-standards-check

default:
cmds:
- task --list
silent: true
12 changes: 12 additions & 0 deletions bin/generate
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ $services = [
],
'namespace_name' => 'SF1600',
],

// https://digitaliseringskataloget.dk/integration/sf2900
'sf2900' => [
'doc_url' => 'https://docs.kombit.dk/integration/sf2900/2.4/pakke',
'resource_zip_glob' => 'SF2900 Teknisk Spec*.zip',
'wsdl_paths' => [
'' => 'wsdl/context/DistributionService.wsdl',
],
'namespace_name' => 'SF2900',
// @see https://github.com/WsdlToPhp/PackageEws365/blob/master/SoapClient/SoapClientBase.php
'soap_client_class' => \ItkDev\Serviceplatformen\Service\SF2900\SoapClientBase::class,
],
];

class ResourceHelper extends Helper {
Expand Down
24 changes: 24 additions & 0 deletions bin/serviceplatformen-sf2900-fordelingsmodtager-list
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env php
<?php

/**
* This file is part of itk-dev/serviceplatformen.
*
* (c) 2025 ITK Development
*
* This source file is subject to the MIT license.
*/

// @see https://getcomposer.org/doc/articles/vendor-binaries.md#finding-the-composer-autoloader-from-a-binary
require $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';

use ItkDev\Serviceplatformen\Command\SF2900\FordelingsmodtagerListCommand;
use Symfony\Component\Console\Application;

$application = new Application('SF2900', '1.0.0');
$command = new FordelingsmodtagerListCommand();

$application->add($command);

$application->setDefaultCommand($command->getName(), true);
$application->run();
24 changes: 24 additions & 0 deletions bin/serviceplatformen-sf2900-fordelingsobjekt-afsend
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env php
<?php

/**
* This file is part of itk-dev/serviceplatformen.
*
* (c) 2025 ITK Development
*
* This source file is subject to the MIT license.
*/

// @see https://getcomposer.org/doc/articles/vendor-binaries.md#finding-the-composer-autoloader-from-a-binary
require $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';

use ItkDev\Serviceplatformen\Command\SF2900\FordelingsobjektAfsendCommand;
use Symfony\Component\Console\Application;

$application = new Application('SF2900', '1.0.0');
$command = new FordelingsobjektAfsendCommand();

$application->add($command);

$application->setDefaultCommand($command->getName(), true);
$application->run();
24 changes: 24 additions & 0 deletions bin/serviceplatformen-sf2900-sftp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env php
<?php

/**
* This file is part of itk-dev/serviceplatformen.
*
* (c) 2025 ITK Development
*
* This source file is subject to the MIT license.
*/

// @see https://getcomposer.org/doc/articles/vendor-binaries.md#finding-the-composer-autoloader-from-a-binary
require $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';

use ItkDev\Serviceplatformen\Command\SF2900\SftpCommand;
use Symfony\Component\Console\Application;

$application = new Application('SF2900', '1.0.0');
$command = new SftpCommand();

$application->add($command);

$application->setDefaultCommand($command->getName(), true);
$application->run();
19 changes: 19 additions & 0 deletions bin/xsd2php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ xsd_dir=/tmp/serviceplatformen/xsd
# XSD archive url (cf. https://www.digitaliser.dk/resource/5248921)
XSD_ARCHIVE_URL="https://www.digitaliser.dk/resource/5248921/artefact/MeMo_XSD.zip?artefact=true&PID=6075979"

# @todo
# The previous XSD_ARCHIVE_URL does no longer exist.
# https://www.digitaliser.dk/resource/5248921 » "MeMo v1.1 dokumentationen"
# (https://www.digitaliser.dk/digital-post/vejledninger/memo-v11) »
# "MeMo_XSD.zip" leads to
# XSD_ARCHIVE_URL="https://www.digitaliser.dk/Media/638142936027043458/MeMo_XSD.zip"

echo "${bold}Fetching MeMo XSD${normal}"

mkdir -p "$xsd_dir"
Expand Down Expand Up @@ -78,3 +85,15 @@ unzip -q -o "$xsd_dir/SF1500 Bilag*.zip" -d "$xsd_dir" || true
ls -l "$xsd_dir"/Tekniske*/*/xsd/6.0.STS-0/*.xsd

"$project_dir"/vendor/bin/xsd2php convert xsd2php-config.yml "$xsd_dir"/Tekniske*/*/xsd/6.0.STS-0/*.xsd

# https://digitaliseringskataloget.dk/sites/default/files/integration-files/091220250945/Vejledning%20til%20Serviceplatformens%20SFTP%20Service.pdf

xsd_dir=/tmp/sftp/xsd
mkdir -p "$xsd_dir"

set -x

curl --silent --location https://docs.kombit.dk/latest/0cfee71a >| "$xsd_dir"/sftp.zip
unzip -q -o "$xsd_dir"/sftp.zip -d "$xsd_dir"

"$project_dir"/vendor/bin/xsd2php convert xsd2php-config.yml "$xsd_dir"/*/xsd/*.xsd
36 changes: 36 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
services:
phpfpm:
image: itkdev/php8.3-fpm:latest
user: ${COMPOSE_USER:-deploy}
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
- PHP_XDEBUG_MODE=${PHP_XDEBUG_MODE:-off}
- PHP_MAX_EXECUTION_TIME=30
- PHP_MEMORY_LIMIT=256M
# - DOCKER_HOST_DOMAIN=${COMPOSE_DOMAIN}
- PHP_IDE_CONFIG=serverName=localhost
volumes:
- .:/app
# environment:
# PHP_MEMORY_LIMIT: 512M
# COMPOSER_MEMORY_LIMIT: -1

# Code checks tools
markdownlint:
image: itkdev/markdownlint
profiles:
- dev
volumes:
- ./:/md

prettier:
# Prettier does not (yet, fcf.
# https://github.com/prettier/prettier/issues/15206) have an official
# docker image.
# https://hub.docker.com/r/jauderho/prettier is good candidate (cf. https://hub.docker.com/search?q=prettier&sort=updated_at&order=desc)
image: jauderho/prettier
profiles:
- dev
volumes:
- ./:/work
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,33 @@
"bin/serviceplatformen-sf1601-kombipostafsend"
],
"require": {
"php": "^8.1",
"php": "^8.3",
"ext-curl": "*",
"ext-dom": "*",
"ext-json": "*",
"ext-openssl": "*",
"ext-simplexml": "*",
"ext-soap": "*",
"ext-xsl": "*",
"composer-runtime-api": "^2.2",
"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",
"phpseclib/phpseclib": "^3.0",
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
"symfony/event-dispatcher": "^6.0 || ^7.0",
"symfony/http-client": "^5.4 || ^6.0 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.0 || ^7.0",
"symfony/property-access": "^5.4 || ^6.0 || ^7.0",
"symfony/property-access": "^4.4 || ^5.4 || ^6.0 || ^7.0",
"symfony/string": "^5.4 || ^6.0 || ^7.0",
"symfony/uid": "^5.4 || ^6.0 || ^7.0",
"wsdltophp/packagebase": "^5.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.11",
"goetas-webservices/xsd2php": "dev-feature-xml-namespace-prefix",
"goetas-webservices/xsd2php": "dev-feature-xml-namespace-prefix#itk-0.4.14",
"phan/phan": "^5.4",
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^9.0",
Expand All @@ -60,6 +63,7 @@
"ItkDev\\Serviceplatformen\\": "src/",
"ItkDev\\Serviceplatformen\\SF1500\\": "generated-classes/ItkDev/Serviceplatformen/SF1500/",
"ItkDev\\Serviceplatformen\\SF1600\\": "generated-classes/ItkDev/Serviceplatformen/SF1600/",
"ItkDev\\Serviceplatformen\\SF2900\\": "generated-classes/ItkDev/Serviceplatformen/SF2900/",
"DigitalPost\\MeMo\\": "lib/DigitalPost/MeMo/",
"DataGovDk\\Model\\DataTypes\\": "lib/DataGovDk/Model/DataTypes/",
"DataGovDk\\Model\\Core\\": "lib/DataGovDk/Model/Core/",
Expand Down
Loading
Loading