Skip to content

Commit 2e48a4b

Browse files
chore(merge): merge pull request #1 from openapi/dev
Update PHP version & shrink codebase
2 parents 4d31082 + 0c1a185 commit 2e48a4b

61 files changed

Lines changed: 805 additions & 5559 deletions

Some content is hidden

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

.github/pull_request_template.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## 📋 Description
2+
3+
Brief description of the changes made in this PR.
4+
5+
## ✨ Type of Change
6+
7+
- [ ] 🐛 Bug fix (fixes an issue)
8+
- [ ] ✨ New feature (adds functionality)
9+
- [ ] 🔧 Refactoring (code restructuring without functional changes)
10+
- [ ] 📚 Documentation (updates to documentation)
11+
- [ ] 🧪 Tests (adding or modifying tests)
12+
- [ ] 🔒 Security (security-related fixes)
13+
- [ ] ⚡ Performance (performance improvements)
14+
- [ ] 🎨 Style (formatting changes, no logic changes)
15+
16+
## 🔍 Main Changes
17+
18+
-
19+
-
20+
-
21+
22+
## 🧪 Testing
23+
24+
- [ ] I have tested the changes locally
25+
- [ ] I have added/updated unit tests
26+
- [ ] All tests pass (`./vendor/bin/phpunit`)
27+
- [ ] I have verified PHP 8.0+ compatibility
28+
29+
## 📝 Additional Notes
30+
31+
Any additional information, considerations, or important context for reviewers.
32+
33+
## 🔗 Related Issue
34+
35+
Closes #[issue_number] (if applicable)
36+
37+
## 📸 Screenshots (if applicable)
38+
39+
If changes affect the interface or visible behavior, include screenshots.
40+
41+
## ✅ Checklist
42+
43+
- [ ] My code follows the project conventions
44+
- [ ] I have performed a self-review of my code
45+
- [ ] I have commented complex code where necessary
46+
- [ ] Documentation has been updated (if needed)
47+
- [ ] I have not introduced breaking changes (or documented them)
48+
- [ ] I have verified no sensitive information is in the code

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
.idea/
22
.vscode/
3+
reference/
34
/vendor/
45
node_modules/
56
npm-debug.log
67
yarn-error.log
78
storage/*.key
89
.env
10+
composer.lock
911
Homestead.yaml
1012
Homestead.json
1113
/.vagrant

CLAUDE.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Language Policy
6+
7+
**IMPORTANT:** The primary language for this codebase is English. All code, comments, documentation, commit messages, PR descriptions, and communications should be in English.
8+
9+
## Development Commands
10+
11+
### Testing
12+
```bash
13+
# Run PHPUnit tests
14+
./vendor/bin/phpunit tests/
15+
16+
# Run specific test file
17+
./vendor/bin/phpunit tests/ApiClientTest.php
18+
19+
# Note: Most integration tests are skipped by default as they require valid API tokens
20+
```
21+
22+
### Dependencies
23+
```bash
24+
# Install Composer dependencies
25+
composer install
26+
27+
# Install dev dependencies
28+
composer install --dev
29+
```
30+
31+
### Git Workflow
32+
```bash
33+
# Quick development push (defined in Makefile)
34+
make dev-push
35+
```
36+
37+
## Architecture Overview
38+
39+
This is a minimal, agnostic PHP SDK for OpenAPI services with only essential HTTP primitives. The architecture follows a clean, simple design inspired by the Rust implementation found in `reference/openapi-rust-sdk/`.
40+
41+
### Core Components
42+
43+
- **`OauthClient`** (`src/OauthClient.php`): Handles OAuth authentication and token management
44+
- Uses Basic Auth with username/apikey for authentication
45+
- Supports both production (`oauth.openapi.it`) and test (`test.oauth.openapi.it`) environments
46+
- Methods: `getScopes()`, `createToken()`, `getTokens()`, `deleteToken()`, `getCounters()`
47+
48+
- **`Client`** (`src/Client.php`): Agnostic HTTP client for making API calls
49+
- Uses Bearer token authentication
50+
- Supports GET, POST, PUT, DELETE, PATCH methods
51+
- Handles URL parameter encoding for GET requests
52+
- JSON payload encoding for POST/PUT/PATCH requests
53+
- 30-second timeout for all requests
54+
55+
- **`Exception`** (`src/Exception.php`): Custom exception handling for HTTP and cURL errors
56+
57+
- **Cache System** (`src/Cache/`): Optional caching interface with array-based implementation
58+
- `CacheInterface`: Contract for cache implementations
59+
- `ArrayCache`: In-memory cache implementation
60+
61+
### Key Design Principles
62+
63+
1. **Agnostic**: No API-specific classes - works with any OpenAPI service
64+
2. **Minimal**: Only core HTTP primitives, minimal dependencies (PHP 8.0+, cURL, JSON)
65+
3. **Clean Interface**: Simple method signatures following REST conventions
66+
4. **Environment Flexibility**: Built-in test/production environment switching
67+
68+
### Examples Usage Patterns
69+
70+
The `examples/` directory contains practical usage demonstrations:
71+
- Token generation with OAuth client
72+
- API calls with different HTTP methods
73+
- Complete workflow integration
74+
75+
### PSR-4 Autoloading
76+
77+
The project uses PSR-4 autoloading with `OpenApi\` namespace mapped to `src/` directory.
78+
79+
## Requirements
80+
81+
- PHP 8.0+
82+
- cURL extension
83+
- JSON extension
84+
- PHPUnit 9.5+ for testing

0 commit comments

Comments
 (0)