Skip to content

Commit c72c294

Browse files
committed
feat: add CLAUDE.md for project guidance and testing instructions
1 parent 85d5c98 commit c72c294

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

CLAUDE.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
### Testing
8+
- `vendor/bin/phpunit` - Run all tests
9+
- `vendor/bin/phpunit --coverage-clover coverage.xml` - Run tests with coverage
10+
- `vendor/bin/phpunit --configuration phpunit.php8.1.xml.dist` - Run tests for specific PHP version
11+
- `vendor/bin/phpunit tests/Unit` - Run only unit tests
12+
- `vendor/bin/phpunit tests/Feature` - Run only feature tests
13+
14+
### Static Analysis
15+
- `vendor/bin/phpstan analyze` - Run PHPStan static analysis (level 6)
16+
17+
### Dependencies
18+
- `composer install` - Install dependencies
19+
- `composer require laravel/framework ^9.0` - Install specific Laravel version for testing
20+
21+
## Architecture
22+
23+
This is a Laravel package that provides JSON:API compliant resource serialization. The core architecture follows these patterns:
24+
25+
### Resource System
26+
- **JsonApiResource**: Main abstract class extending Laravel's JsonResource, implements JSON:API specification
27+
- **JsonApiCollection**: Handles collections of resources with proper JSON:API formatting
28+
- **Resourceable**: Interface defining resource contracts
29+
30+
### Key Components
31+
32+
#### Descriptors
33+
- **Values** (`src/Descriptors/Values`): Type descriptors for attributes (string, integer, float, date, enum, etc.)
34+
- **Relations** (`src/Descriptors/Relations`): Relationship descriptors (one, many)
35+
36+
#### Resource Concerns
37+
- **Attributes**: Handles attribute serialization with field filtering
38+
- **Relationships**: Manages relationship loading and serialization with include support
39+
- **ConditionallyLoadsAttributes**: Laravel-style conditional attribute support
40+
- **Identifier**: Resource ID and type handling
41+
- **Links**: JSON:API links support
42+
- **Meta**: Meta information handling
43+
- **Schema**: Resource schema generation for validation
44+
- **ToResponse**: Response formatting
45+
46+
#### Request Validation
47+
- **Rules/Includes**: Validates `include` parameter against resource schema
48+
- **Rules/Fields**: Validates `fields` parameter for sparse fieldsets
49+
50+
### Key Features
51+
- **Include Support**: Dynamic relationship loading via `?include=` parameter
52+
- **Sparse Fieldsets**: Attribute filtering via `?fields[type]=` parameter
53+
- **Described Notation**: Fluent API for defining attributes and relationships with type casting
54+
- **Laravel Compatibility**: Supports Laravel 9-12 and PHP 8.1-8.4
55+
56+
### Configuration
57+
The package includes a config file (`config/jsonapi.php`) with settings for:
58+
- Nullable value handling
59+
- Date formatting
60+
- Float precision
61+
- Automatic whenHas conditions
62+
- Relationship loading behavior
63+
64+
### Testing Structure
65+
- **Unit Tests**: Test individual components in isolation
66+
- **Feature Tests**: Test complete JSON:API response formatting
67+
- Uses Orchestra Testbench for Laravel package testing
68+
- SQLite in-memory database for testing

0 commit comments

Comments
 (0)