Skip to content

Commit 8384684

Browse files
Ardenexalclaude
andcommitted
feat: initial release of PHP FHIR Tools
Multi-component toolkit for working with FHIR (Fast Healthcare Interoperability Resources) in PHP: - CodeGeneration: Generate PHP model classes and enums from FHIR Structure Definitions - Serialization: FHIR-compliant JSON/XML serialization and deserialization - FHIRPath: FHIRPath expression evaluator - FHIRBundle: Symfony Bundle integration with console commands - Models: Pre-generated R4 model classes Requires PHP 8.3+, Symfony 6.4, PHPStan level 8, PSR-12 compliant. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0 parents  commit 8384684

1,467 files changed

Lines changed: 102252 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/Dockerfile

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Use official PHP 8.3 image with CLI and development tools
2+
FROM php:8.3-cli
3+
4+
# Install system dependencies
5+
RUN apt-get update && apt-get install -y \
6+
git \
7+
curl \
8+
libpng-dev \
9+
libonig-dev \
10+
libxml2-dev \
11+
libzip-dev \
12+
zip \
13+
unzip \
14+
wget \
15+
gnupg2 \
16+
software-properties-common \
17+
ca-certificates \
18+
lsb-release \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# Install PHP extensions required by the project
22+
RUN docker-php-ext-install \
23+
ctype \
24+
iconv \
25+
zip \
26+
intl \
27+
mbstring \
28+
xml
29+
30+
# Install Xdebug for debugging and coverage
31+
RUN pecl install xdebug-3.3.1 \
32+
&& docker-php-ext-enable xdebug
33+
34+
# Install Composer
35+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
36+
37+
# Create a non-root user
38+
ARG USERNAME=vscode
39+
ARG USER_UID=1000
40+
ARG USER_GID=$USER_UID
41+
42+
RUN groupadd --gid $USER_GID $USERNAME \
43+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
44+
&& apt-get update \
45+
&& apt-get install -y sudo \
46+
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
47+
&& chmod 0440 /etc/sudoers.d/$USERNAME
48+
49+
# Set up Composer cache directory
50+
RUN mkdir -p /home/$USERNAME/.composer \
51+
&& chown -R $USERNAME:$USERNAME /home/$USERNAME/.composer
52+
53+
# Install Node.js (useful for any frontend tooling)
54+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
55+
&& apt-get install -y nodejs
56+
57+
# Install additional development tools
58+
RUN apt-get update && apt-get install -y \
59+
vim \
60+
nano \
61+
htop \
62+
tree \
63+
jq \
64+
&& rm -rf /var/lib/apt/lists/*
65+
66+
# Set working directory
67+
WORKDIR /workspace
68+
69+
# Switch to non-root user
70+
USER $USERNAME
71+
72+
# Set up shell environment
73+
RUN echo 'export PATH="$PATH:/workspace/vendor/bin"' >> /home/$USERNAME/.bashrc \
74+
&& echo 'alias ll="ls -la"' >> /home/$USERNAME/.bashrc \
75+
&& echo 'alias la="ls -la"' >> /home/$USERNAME/.bashrc \
76+
&& echo 'alias phpunit="./vendor/bin/phpunit"' >> /home/$USERNAME/.bashrc \
77+
&& echo 'alias phpstan="./vendor/bin/phpstan.phar"' >> /home/$USERNAME/.bashrc \
78+
&& echo 'alias pint="./vendor/bin/pint"' >> /home/$USERNAME/.bashrc
79+
80+
# Configure Git (will be overridden by user's git config)
81+
RUN git config --global init.defaultBranch main \
82+
&& git config --global pull.rebase false

.devcontainer/devcontainer.json

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"name": "PHP FHIRTools Development",
3+
"dockerComposeFile": "docker-compose.yml",
4+
"service": "php",
5+
"workspaceFolder": "/workspace",
6+
7+
"features": {
8+
"ghcr.io/devcontainers/features/git:1": {
9+
"ppa": true,
10+
"version": "latest"
11+
},
12+
"ghcr.io/devcontainers/features/github-cli:1": {
13+
"installDirectlyFromGitHubRelease": true,
14+
"version": "latest"
15+
},
16+
"ghcr.io/devcontainers/features/common-utils:2": {
17+
"installZsh": true,
18+
"configureZshAsDefaultShell": true,
19+
"installOhMyZsh": true,
20+
"upgradePackages": true,
21+
"username": "vscode",
22+
"userUid": "automatic",
23+
"userGid": "automatic"
24+
}
25+
},
26+
27+
"customizations": {
28+
"vscode": {
29+
"extensions": [
30+
"bmewburn.vscode-intelephense-client",
31+
"xdebug.php-debug",
32+
"zobo.php-intellisense",
33+
"ms-vscode.vscode-json",
34+
"redhat.vscode-yaml",
35+
"bradlc.vscode-tailwindcss",
36+
"formulahendry.auto-rename-tag",
37+
"ms-azuretools.vscode-docker",
38+
"eamodio.gitlens",
39+
"github.copilot",
40+
"github.copilot-chat",
41+
"ms-vscode.test-adapter-converter",
42+
"recca0120.vscode-phpunit",
43+
"sanderronde.phpstan-vscode",
44+
"open-southeners.laravel-pint"
45+
],
46+
"settings": {
47+
"php.validate.executablePath": "/usr/local/bin/php",
48+
"php.debug.executablePath": "/usr/local/bin/php",
49+
"intelephense.files.maxSize": 5000000,
50+
"intelephense.telemetry.enabled": false,
51+
"intelephense.format.enable": false,
52+
"editor.formatOnSave": true,
53+
"editor.codeActionsOnSave": {
54+
"source.fixAll": "explicit"
55+
},
56+
"files.associations": {
57+
"*.php": "php",
58+
"composer.lock": "json"
59+
},
60+
"terminal.integrated.defaultProfile.linux": "zsh",
61+
"git.enableCommitSigning": true,
62+
"phpunit.php": "/usr/local/bin/php",
63+
"phpunit.phpunit": "./vendor/bin/phpunit",
64+
"phpunit.args": [
65+
"--configuration",
66+
"phpunit.dist.xml"
67+
],
68+
"phpstan.enabled": true,
69+
"phpstan.path": "./vendor/bin/phpstan.phar",
70+
"phpstan.configFile": "./phpstan.neon"
71+
}
72+
}
73+
},
74+
75+
"forwardPorts": [8000, 9000, 9003],
76+
"portsAttributes": {
77+
"8000": {
78+
"label": "Symfony Dev Server",
79+
"onAutoForward": "notify"
80+
},
81+
"9000": {
82+
"label": "PHP-FPM",
83+
"onAutoForward": "silent"
84+
},
85+
"9003": {
86+
"label": "Xdebug",
87+
"onAutoForward": "silent"
88+
}
89+
},
90+
91+
"postCreateCommand": ".devcontainer/setup.sh",
92+
"postStartCommand": "composer install --no-interaction",
93+
94+
"remoteUser": "vscode",
95+
"containerUser": "vscode",
96+
97+
"mounts": [
98+
"source=${localWorkspaceFolder}/.devcontainer/php.ini,target=/usr/local/etc/php/conf.d/99-custom.ini,type=bind",
99+
"source=fhir-tools-composer-cache,target=/home/vscode/.composer,type=volume"
100+
]
101+
}

.devcontainer/docker-compose.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: '3.8'
2+
3+
services:
4+
php:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
volumes:
9+
- ../:/workspace:cached
10+
- composer-cache:/home/vscode/.composer
11+
environment:
12+
- APP_ENV=dev
13+
- XDEBUG_MODE=develop,debug,coverage
14+
- XDEBUG_CONFIG=client_host=host.docker.internal client_port=9003 start_with_request=yes
15+
- PHP_IDE_CONFIG=serverName=fhir-tools
16+
command: sleep infinity
17+
networks:
18+
- fhir-tools
19+
20+
# Optional: Add a database if needed for future FHIR data storage
21+
# postgres:
22+
# image: postgres:16-alpine
23+
# environment:
24+
# POSTGRES_DB: fhir_tools
25+
# POSTGRES_USER: fhir_user
26+
# POSTGRES_PASSWORD: fhir_password
27+
# volumes:
28+
# - postgres-data:/var/lib/postgresql/data
29+
# ports:
30+
# - "5432:5432"
31+
# networks:
32+
# - fhir-tools
33+
34+
volumes:
35+
composer-cache:
36+
# postgres-data:
37+
38+
networks:
39+
fhir-tools:
40+
driver: bridge

.devcontainer/php.ini

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
; PHP Configuration for FHIRTools Development
2+
3+
; Memory and execution limits
4+
memory_limit = 512M
5+
max_execution_time = 300
6+
max_input_time = 300
7+
8+
; Error reporting for development
9+
display_errors = On
10+
display_startup_errors = On
11+
error_reporting = E_ALL
12+
log_errors = On
13+
error_log = /tmp/php_errors.log
14+
15+
; File upload limits (for FHIR packages)
16+
upload_max_filesize = 100M
17+
post_max_size = 100M
18+
max_file_uploads = 20
19+
20+
; Timezone
21+
date.timezone = UTC
22+
23+
; Xdebug configuration
24+
xdebug.mode = develop,debug,coverage
25+
xdebug.start_with_request = yes
26+
xdebug.client_host = host.docker.internal
27+
xdebug.client_port = 9003
28+
xdebug.idekey = VSCODE
29+
xdebug.log = /tmp/xdebug.log
30+
xdebug.log_level = 0
31+
32+
; Coverage settings
33+
xdebug.coverage_enable = 1
34+
35+
; Profiling (disabled by default, enable when needed)
36+
; xdebug.profiler_enable = 0
37+
; xdebug.profiler_output_dir = /tmp
38+
39+
; OPcache settings for development
40+
opcache.enable = 1
41+
opcache.enable_cli = 1
42+
opcache.memory_consumption = 128
43+
opcache.interned_strings_buffer = 8
44+
opcache.max_accelerated_files = 4000
45+
opcache.revalidate_freq = 2
46+
opcache.fast_shutdown = 1
47+
opcache.validate_timestamps = 1
48+
49+
; Security settings
50+
expose_php = Off
51+
allow_url_fopen = On
52+
allow_url_include = Off
53+
54+
; Session settings
55+
session.cookie_httponly = 1
56+
session.use_strict_mode = 1
57+
58+
; Mbstring settings
59+
mbstring.language = English
60+
mbstring.encoding_translation = Off

.devcontainer/setup.sh

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
3+
# FHIRTools Development Container Setup Script
4+
set -e
5+
6+
echo "🚀 Setting up PHP FHIRTools development environment..."
7+
8+
# Make sure we're in the workspace directory
9+
cd /workspace
10+
11+
# Install Composer dependencies if not already installed
12+
if [ ! -d "vendor" ]; then
13+
echo "📦 Installing Composer dependencies..."
14+
composer install --no-interaction --optimize-autoloader
15+
else
16+
echo "✅ Composer dependencies already installed"
17+
fi
18+
19+
# Set up Git hooks directory (if using)
20+
if [ -d ".git" ]; then
21+
echo "🔧 Configuring Git..."
22+
git config --local core.hooksPath .githooks 2>/dev/null || true
23+
fi
24+
25+
# Create necessary directories
26+
echo "📁 Creating necessary directories..."
27+
mkdir -p output
28+
mkdir -p var/cache
29+
mkdir -p var/log
30+
mkdir -p coverage
31+
32+
# Set proper permissions
33+
echo "🔐 Setting permissions..."
34+
chmod -R 755 bin/console 2>/dev/null || true
35+
chmod -R 777 var/ 2>/dev/null || true
36+
chmod -R 777 coverage/ 2>/dev/null || true
37+
38+
# Verify PHP configuration
39+
echo "🔍 Verifying PHP configuration..."
40+
php -v
41+
php -m | grep -E "(xdebug|zip|ctype|iconv|intl)" || echo "⚠️ Some extensions may be missing"
42+
43+
# Test Composer scripts
44+
echo "🧪 Testing Composer scripts..."
45+
composer run-script --list
46+
47+
# Verify Symfony console
48+
echo "🎯 Testing Symfony console..."
49+
php bin/console --version
50+
51+
# Run initial code quality checks
52+
echo "🔍 Running initial code quality checks..."
53+
if [ -f "vendor/bin/phpstan.phar" ]; then
54+
echo "Running PHPStan..."
55+
composer run phpstan || echo "⚠️ PHPStan found issues - check output above"
56+
else
57+
echo "⚠️ PHPStan not found - run 'composer install' to install dev dependencies"
58+
fi
59+
60+
if [ -f "vendor/bin/pint" ]; then
61+
echo "Running Pint (code style)..."
62+
composer run lint || echo "⚠️ Pint found style issues - check output above"
63+
else
64+
echo "⚠️ Pint not found - run 'composer install' to install dev dependencies"
65+
fi
66+
67+
# Display helpful information
68+
echo ""
69+
echo "🎉 Development environment setup complete!"
70+
echo ""
71+
echo "📋 Available commands:"
72+
echo " composer run test - Run PHPUnit tests"
73+
echo " composer run test-coverage - Run tests with coverage"
74+
echo " composer run phpstan - Run static analysis"
75+
echo " composer run lint - Fix code style"
76+
echo " php bin/console list - List available console commands"
77+
echo " php bin/console fhir:generate --help - FHIR generation help"
78+
echo ""
79+
echo "🐛 Debugging:"
80+
echo " - Xdebug is configured on port 9003"
81+
echo " - Set breakpoints in VS Code and start debugging"
82+
echo " - Use 'Listen for Xdebug' configuration"
83+
echo ""
84+
echo "📁 Important directories:"
85+
echo " - src/ - Source code"
86+
echo " - tests/ - Test files"
87+
echo " - output/ - Generated FHIR classes"
88+
echo " - coverage/ - Test coverage reports"
89+
echo ""
90+
echo "Happy coding! 🚀"

0 commit comments

Comments
 (0)