|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | + |
| 6 | +## Quick commands |
| 7 | + |
| 8 | +- Install dependencies: composer install |
| 9 | +- Run unit tests: composer test (runs phpunit) |
| 10 | +- Run tests with coverage: composer run test:coverage |
| 11 | +- Run static analysis: composer run phpstan (phpstan analyse --memory-limit=1G) |
| 12 | +- Run code style checks: composer run cs-fixer:check |
| 13 | +- Auto-fix code style: composer run cs-fixer:fix |
| 14 | +- Full check: composer run check (runs cs-fixer check, phpstan, and test coverage) |
| 15 | +- Lint (style + static analysis): composer run lint |
| 16 | + |
| 17 | +To run a single PHPUnit test (by file): |
| 18 | +- ./vendor/bin/phpunit path/to/TestFile.php |
| 19 | + |
| 20 | +To run a single test method: |
| 21 | +- ./vendor/bin/phpunit --filter testMethodName path/to/TestFile.php |
| 22 | + |
| 23 | + |
| 24 | +## Project overview — high level |
| 25 | + |
| 26 | +This repository provides a small PHP SDK for Staffbase plugin Single Sign-On (SSO) token parsing and validation. |
| 27 | + |
| 28 | +High-level structure: |
| 29 | + |
| 30 | +- src/: Core library code. Primary classes: |
| 31 | + - src/SSOToken.php — main JWT parsing & validation wrapper for plugin SSO tokens (uses lcobucci/jwt) |
| 32 | + - src/SSOTokenGenerator.php — utility to generate test tokens for unit tests |
| 33 | + - src/PluginSession.php — session wrapper for persisting SSO data between requests |
| 34 | + - src/RemoteCall/* — handlers and interfaces for app-initiated remote calls (delete-instance, etc.) |
| 35 | + - src/SSOData/* — data interfaces/traits for shared and SSO specific claims |
| 36 | + - src/Exceptions/* — domain exceptions (SSOAuthenticationException, SSOException, ...) |
| 37 | + - src/Validation/* — custom validation constraints used by php-jwt/token validation |
| 38 | + - src/AbstractToken.php — base token parsing/verification logic used by SSOToken and others |
| 39 | + |
| 40 | +- test/: PHPUnit test suite for the library. Tests instantiate SSOToken, SSOTokenGenerator and validate behavior. |
| 41 | + |
| 42 | +- composer.json: Composer metadata and scripts (lint, phpstan, tests, cs-fixer). Key runtime deps: lcobucci/jwt, lcobucci/clock. |
| 43 | + |
| 44 | +- phpstan.neon.dist: phpstan configuration (analyse src and test at level 4 by default). |
| 45 | + |
| 46 | +- README.md: user-facing documentation and examples (installation, usage examples, remote calls). |
| 47 | + |
| 48 | + |
| 49 | +## CI and hooks |
| 50 | + |
| 51 | +- GitHub Actions: a workflow badge exists in README, check .github/workflows for exact CI steps if needed. |
| 52 | +- Composer hooks: composer.json registers post-install and post-update hooks for composer-git-hooks. Pre-commit hooks in composer.extra.hooks run "composer fix" and "composer phpstan". |
| 53 | + |
| 54 | + |
| 55 | +## Notes for future Claude Code instances |
| 56 | + |
| 57 | +- Use Composer scripts defined in composer.json for all common operations (tests, lint, phpstan, cs-fixer). Prefer the scripts so local project configuration is respected. |
| 58 | +- When adding or editing PHP code, run CS Fixer and PHPStan locally (composer run fix; composer run phpstan) before running tests. |
| 59 | +- Tests are run with phpunit (vendor/bin/phpunit). For debugging a single test, prefer running vendor/bin/phpunit --filter. |
| 60 | + |
| 61 | +Key files to inspect for behavior changes: |
| 62 | +- src/SSOToken.php: constructor, token parsing and validation flow |
| 63 | +- src/AbstractToken.php: core token parsing/verification logic |
| 64 | +- src/Validation/HasInstanceId.php: custom constraint used by SSOToken |
| 65 | +- README.md and doc/api.md: user-visible behavior and API |
| 66 | + |
| 67 | + |
| 68 | +## When editing code |
| 69 | + |
| 70 | +- Prefer editing existing files rather than creating new ones unless a new module is required. |
| 71 | +- Follow PSR-4 autoloading in composer.json (namespace Staffbase\plugins\sdk\ -> src/) |
| 72 | +- Keep phpstan.neon.dist level consideration in mind |
| 73 | + |
| 74 | + |
| 75 | +## Contact and references |
| 76 | + |
| 77 | +- Project homepage: https://github.com/Staffbase/plugins-sdk-php |
| 78 | +- Composer entry: composer.json |
| 79 | + |
0 commit comments