Skip to content

Commit 4c06ede

Browse files
skydudieclaude
andcommitted
chore: prepare v0.1.0 release (PR 2.9)
- Add CHANGELOG.md documenting what shipped in 0.1.0 + the known limitations (it's lift-and-shift; spec compliance is Phase 4 work). - Update README status banner from "Work in progress; do not depend on it" to "Pre-1.0". - Add a real usage example to the README (HttpDocumentLoader + Guzzle). - Refresh the v1.0 scope checklist: DocumentLoader is done, Expansion is present-but-not-spec-compliant, Compaction + toRdf still pending. Tag v0.1.0 is created separately so this commit can be reviewed without binding the tag prematurely. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent aa9a124 commit 4c06ede

3 files changed

Lines changed: 121 additions & 9 deletions

File tree

.gitattributes

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Force LF line endings for all text files. Overrides Windows checkout-time
2+
# CRLF conversion (core.autocrlf=true) so contributors on different platforms
3+
# see the same bytes regardless of local git config.
4+
* text=auto eol=lf
5+
6+
# Binary file types — never touch line endings.
7+
*.png binary
8+
*.jpg binary
9+
*.gif binary
10+
*.ico binary
11+
*.pdf binary
12+
13+
# Files that don't need to ship in the composer dist tarball.
14+
# These cut the size of `composer require` downloads significantly,
15+
# especially the W3C submodule (tests/w3c/).
16+
/.editorconfig export-ignore
17+
/.gitattributes export-ignore
18+
/.gitignore export-ignore
19+
/.gitmodules export-ignore
20+
/.github export-ignore
21+
/CHANGELOG.md export-ignore
22+
/Pest.php export-ignore
23+
/phpstan.neon.dist export-ignore
24+
/phpunit.xml export-ignore
25+
/tests export-ignore

CHANGELOG.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Changelog
2+
3+
All notable changes to `accredifysg/php-json-ld` are documented here.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.1.0] - 2026-05-13
11+
12+
Initial release. Extracts the JSON-LD context loader + expander out of
13+
[accredifysg/verifiable-credentials-php](https://github.com/accredifysg/verifiable-credentials-php)
14+
into a standalone package. Behaviourally identical to that repo's
15+
pre-extraction implementation — see the
16+
[characterization tests](tests/Algorithms/Characterization/) for the
17+
byte-equal proof.
18+
19+
This release is **not spec-compliant with JSON-LD 1.1**. It is shipped
20+
so the VC repo can consume the package in Phase 3 without behaviour
21+
change. Spec-compliance work lands incrementally in Phase 4.
22+
23+
### Added
24+
25+
- `Accredify\JsonLd\JsonLdProcessor` — top-level processor, exposes `expand()`.
26+
- `Accredify\JsonLd\Contracts\Processor` — public interface.
27+
- `Accredify\JsonLd\Contracts\DocumentLoader` — pluggable `@context` URL resolver.
28+
- `Accredify\JsonLd\Loaders\HttpDocumentLoader` — default PSR-18 + PSR-17
29+
loader. Throws `DocumentLoaderException` on fetch/parse failure.
30+
- `Accredify\JsonLd\Loaders\CachingDocumentLoader` — in-process cache
31+
decorator.
32+
- `Accredify\JsonLd\Context\ContextProcessor` — flattens layered
33+
`@context` declarations into a single term map.
34+
- `Accredify\JsonLd\Context\TermDefinitions` — term → definition value
35+
object.
36+
- `Accredify\JsonLd\Algorithms\Expansion` — expansion routine (partial
37+
JSON-LD 1.1; see characterization tests for current behaviour).
38+
- `Accredify\JsonLd\Documents\ExpandedDocument` — read-only wrapper for
39+
expanded output.
40+
- `Accredify\JsonLd\Documents\RemoteDocument` — DTO for fetched documents.
41+
- `Accredify\JsonLd\Exceptions\JsonLdException` — base exception.
42+
- `Accredify\JsonLd\Exceptions\DocumentLoaderException` — loader failure.
43+
- `Accredify\JsonLd\Enums\Keyword`, `Accredify\JsonLd\Enums\ContainerType`
44+
— JSON-LD 1.1 keyword + container enums.
45+
- W3C JSON-LD 1.1 test suite vendored as a git submodule under
46+
`tests/w3c/`, with a Pest-driven harness at `tests/W3c/` that runs
47+
every manifest as `composer test:w3c`. Currently 1098 tests skipped
48+
(baseline); Phase 4 lifts that count.
49+
50+
### Known limitations (see [the plan](https://github.com/accredifysg/php-json-ld) for the roadmap)
51+
52+
- IRI expansion rejects valid IRIs like `did:`, `urn:`, blank node `_:`.
53+
- No container handling: `@list`, `@set`, `@language`, `@index`,
54+
`@graph`, `@id`, `@type`, `@nest`, `@included`.
55+
- No `@reverse`, `@json`, language-tagged or direction-tagged strings.
56+
- No `@import`, `@propagate`, type-/property-scoped contexts.
57+
- `@base`, `@vocab` stored but not applied during IRI expansion.
58+
- `@protected` validated as boolean but not enforced.
59+
- Hardcoded xsd:string collapse.
60+
- Only `expand` is implemented; `compact` and `toRdf` land in Phase 4.
61+
62+
[Unreleased]: https://github.com/accredifysg/php-json-ld/compare/v0.1.0...HEAD
63+
[0.1.0]: https://github.com/accredifysg/php-json-ld/releases/tag/v0.1.0

README.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99

1010
A PHP implementation of the [JSON-LD 1.1](https://www.w3.org/TR/json-ld11/) specification.
1111

12-
> **Status: Work in progress.** This package is being extracted from
13-
> [accredifysg/verifiable-credentials-php](https://github.com/accredifysg/verifiable-credentials-php)
14-
> and incrementally brought into conformance with the W3C JSON-LD 1.1 specification.
15-
> The public API is not yet stable; do not depend on it for production use until v1.0.
12+
> **Status: Pre-1.0.** v0.1.0 ships the JSON-LD code extracted from
13+
> [accredifysg/verifiable-credentials-php](https://github.com/accredifysg/verifiable-credentials-php).
14+
> It is functionally complete for VCv2 / Open Badges v3 expansion but is
15+
> **not yet spec-compliant** with JSON-LD 1.1 — see
16+
> [CHANGELOG](CHANGELOG.md) for known limitations. The public API may change
17+
> before v1.0.
1618
1719
## Goals
1820

@@ -26,24 +28,46 @@ A PHP implementation of the [JSON-LD 1.1](https://www.w3.org/TR/json-ld11/) spec
2628

2729
## Planned scope (v1.0)
2830

29-
- [ ] Expansion (§5.5)
31+
- [x] Custom `DocumentLoader` interface
32+
- [~] Expansion (§5.5) — present, not spec-compliant yet
3033
- [ ] Compaction (§5.6)
3134
- [ ] Serialize JSON-LD to RDF (§6 / `toRdf`)
32-
- [ ] Custom `DocumentLoader` interface
3335

3436
Out of scope for v1.0: Flattening, Framing, RDF-to-JSON-LD (`fromRdf`).
3537

3638
## Installation
3739

3840
```bash
39-
composer require accredifysg/php-json-ld
41+
composer require accredifysg/php-json-ld:^0.1
4042
```
4143

42-
Requires PHP 8.1+.
44+
Requires PHP 8.1+. You also need a PSR-18 HTTP client + PSR-17 request
45+
factory if you use the bundled `HttpDocumentLoader` (e.g. `guzzlehttp/guzzle`
46+
and `guzzlehttp/psr7`), or you can implement `DocumentLoader` yourself to
47+
serve `@context` URLs from wherever you like.
4348

4449
## Usage
4550

46-
> Usage examples land in a later PR once the public API stabilises.
51+
```php
52+
use Accredify\JsonLd\JsonLdProcessor;
53+
use Accredify\JsonLd\Loaders\CachingDocumentLoader;
54+
use Accredify\JsonLd\Loaders\HttpDocumentLoader;
55+
use GuzzleHttp\Client;
56+
use GuzzleHttp\Psr7\HttpFactory;
57+
58+
$loader = new CachingDocumentLoader(
59+
new HttpDocumentLoader(new Client, new HttpFactory),
60+
);
61+
62+
$processor = new JsonLdProcessor($loader);
63+
$expanded = $processor->expand($yourDocument)->toArray();
64+
```
65+
66+
If you want to serve known contexts from local files (recommended for
67+
verifiable credentials), implement `Accredify\JsonLd\Contracts\DocumentLoader`
68+
yourself. See
69+
[`tests/Algorithms/Characterization/Support/BundledContextLoader.php`](tests/Algorithms/Characterization/Support/BundledContextLoader.php)
70+
for an example.
4771

4872
## Compliance
4973

0 commit comments

Comments
 (0)