|
| 1 | +# Project Guide — ebics-client-php |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +PHP library to communicate with banks through the **EBICS** protocol (Electronic Banking Internet Communication Standard). |
| 6 | +Supports EBICS versions 2.4, 2.5, 3.0 and signature/encryption variants E002, X002, A005, A006. |
| 7 | + |
| 8 | +## Technology Stack |
| 9 | + |
| 10 | +| Item | Version | |
| 11 | +|------|---------| |
| 12 | +| **PHP** | 8.5+ (`^8.5`) | |
| 13 | +| **PHPUnit** | ~10.5 | |
| 14 | +| **PHPStan** | ~2.1 | |
| 15 | +| **PHPCS** | ~3.13 (PSR-12) | |
| 16 | +| **Composer** | latest | |
| 17 | + |
| 18 | +### Required PHP Extensions |
| 19 | + |
| 20 | +`bcmath`, `curl`, `dom`, `json`, `openssl`, `zip`, `zlib`, `libxml` |
| 21 | + |
| 22 | +## Docker Environment |
| 23 | + |
| 24 | +The project uses Docker for a consistent development environment. |
| 25 | + |
| 26 | +``` |
| 27 | +docker/ |
| 28 | +├── docker-compose.yml |
| 29 | +└── php-cli/ |
| 30 | + ├── Dockerfile (php:8.5.4-cli + xdebug + extensions) |
| 31 | + └── php.ini |
| 32 | +``` |
| 33 | + |
| 34 | +### Docker Compose |
| 35 | + |
| 36 | +| Target | Image | Container Name | |
| 37 | +|--------|-------|----------------| |
| 38 | +| `php-cli-ebics-client-php` | `php-cli-ebics-client-php:8.5.4-cli` | `php-cli-ebics-client-php` | |
| 39 | + |
| 40 | +Network mode: **host** (for easy access to local services). |
| 41 | +Xdebug is pre-installed and enabled (port 9003). |
| 42 | + |
| 43 | +### Makefile Targets |
| 44 | + |
| 45 | +| Command | Alias | Description | |
| 46 | +|---------|-------|-------------| |
| 47 | +| `make docker-up` | `u`, `start` | Start Docker containers | |
| 48 | +| `make docker-down` | `d`, `stop` | Stop Docker containers | |
| 49 | +| `make docker-build` | `build` | Rebuild Docker images | |
| 50 | +| `make docker-install` | `install` | Run `composer install` in container | |
| 51 | +| `make docker-php` | `php` | Open a bash shell in the PHP container | |
| 52 | +| `make check` | — | Run PHPCBF, PHPCS, PHPStan, PHPUnit | |
| 53 | +| `make credentials-pack` | — | Zip test credentials | |
| 54 | +| `make credentials-unpack` | — | Unzip test credentials | |
| 55 | + |
| 56 | +### Composer Scripts (run inside Docker) |
| 57 | + |
| 58 | +| Command | Description | |
| 59 | +|---------|-------------| |
| 60 | +| `composer code-test` | Run PHPUnit tests | |
| 61 | +| `composer code-style` | Run PHPCS | |
| 62 | +| `composer code-analyse` | Run PHPStan | |
| 63 | + |
| 64 | +## Directory Structure |
| 65 | + |
| 66 | +``` |
| 67 | +├── src/ # PSR-4: EbicsApi\Ebics\ |
| 68 | +│ ├── Contracts/ # Interfaces |
| 69 | +│ ├── Exceptions/ # Custom exception classes |
| 70 | +│ ├── Factories/ # Factory classes (Crypt, Signature, etc.) |
| 71 | +│ ├── Models/ # Data models (Key, KeyPair, Keyring, Buffer, etc.) |
| 72 | +│ ├── Services/ # Business logic services |
| 73 | +│ └── EbicsClient.php # Main client entry point |
| 74 | +├── tests/ # PSR-4: EbicsApi\Ebics\Tests\ |
| 75 | +│ ├── _data/ # Test data & keyring files |
| 76 | +│ ├── _fixtures/ # Test fixtures (XML files, keys) |
| 77 | +│ ├── _workspace/ # Generated test artifacts |
| 78 | +│ └── AbstractEbicsTestCase.php # Base test class with helpers |
| 79 | +├── doc/schema/ # EBICS XSD schemas |
| 80 | +└── docker/ # Docker configuration |
| 81 | +``` |
| 82 | + |
| 83 | +## Coding Standards |
| 84 | + |
| 85 | +- **PSR-12** coding style (enforced by PHPCS). |
| 86 | +- **PHPStan** level enforced via `phpstan.neon`. |
| 87 | +- Source code lives in `src/`; tests live in `tests/`. |
| 88 | +- PHPCS targets `src/` only (tests excluded in `phpcs.xml`). |
| 89 | +- Tests may use snake_case method names where needed (PHPCS exclusion). |
| 90 | + |
| 91 | +## Running Commands |
| 92 | + |
| 93 | +All commands execute **inside Docker**: |
| 94 | + |
| 95 | +```bash |
| 96 | +# Start environment |
| 97 | +make docker-up |
| 98 | + |
| 99 | +# Run full quality check |
| 100 | +make check |
| 101 | + |
| 102 | +# Or individually: |
| 103 | +docker compose -p ebics-client-php exec php-cli-ebics-client-php ./vendor/bin/phpunit |
| 104 | +docker compose -p ebics-client-php exec php-cli-ebics-client-php ./vendor/bin/phpcs |
| 105 | +docker compose -p ebics-client-php exec php-cli-ebics-client-php ./vendor/bin/phpstan |
| 106 | + |
| 107 | +# Open shell |
| 108 | +make docker-php |
| 109 | +``` |
| 110 | + |
| 111 | +## Testing Conventions |
| 112 | + |
| 113 | +- Base class: `AbstractEbicsTestCase` (provides client setup, keyring, credentials). |
| 114 | +- Test groups (PHPUnit `@group`): e.g. `@group crypt-services`. |
| 115 | +- Credentials stored in `tests/_data/credentials/credentials_<id>.json`. |
| 116 | +- Keyrings stored in `tests/_data/workspace/keyring_<id>.json`. |
| 117 | +- Fixtures (static XML/JSON) in `tests/_fixtures/`. |
| 118 | + |
| 119 | +### Client Setup Helpers |
| 120 | + |
| 121 | +```php |
| 122 | +// In any test extending AbstractEbicsTestCase: |
| 123 | +$client = $this->setupClientV24($credentialsId); // EBICS 2.4 |
| 124 | +$client = $this->setupClientV25($credentialsId); // EBICS 2.5 |
| 125 | +$client = $this->setupClientV30($credentialsId); // EBICS 3.0 |
| 126 | +``` |
| 127 | + |
| 128 | +### Fake / Debug HTTP Clients |
| 129 | + |
| 130 | +Pass `$fake = true` or `$debug = true` to `setupClient*()` to use `FakerHttpClient` (returns fixture data) or `DebuggerHttpClient` (logs requests). |
| 131 | + |
| 132 | +## Key Concepts |
| 133 | + |
| 134 | +| Concept | Description | |
| 135 | +|---------|-------------| |
| 136 | +| **Keyring** | Holds user & bank signatures (A = authentication, X = signing, E = encryption), passwords, and optional X.509 certificates. | |
| 137 | +| **Signature A** | Authentication signature (versions A005 / A006). | |
| 138 | +| **Signature X** | Transaction signing (version X002). | |
| 139 | +| **Signature E** | Encryption (version E002). | |
| 140 | +| **CryptService** | All crypto ops: hashing, AES-128-CBC encrypt/decrypt, RSA sign/encrypt, key generation, nonces, order IDs. | |
| 141 | +| **KeyPair** | Public key + private key + password bundle. | |
| 142 | + |
| 143 | +## Notable Implementation Details |
| 144 | + |
| 145 | +- Classes marked `@internal` may change without notice. |
0 commit comments