Renamed, document and tested static_config_path / static_object_directory

This commit is contained in:
lukas committed 2026-10-18 17:17:41 +00:00
1 parent 55419acb09
commit c4f5504fdf
4 files changed
+94 -6

No files matched your search

+28 -1
View File
@@ -180,4 +180,31 @@ $retriever = new ObjectRetriever([
]);
```
Unlike `static_config_path`, which reads object descriptions that you provide yourself, the permanent store is filled automatically by the SDK from the Object API.
Unlike the [static object directory](#static-objects), which contains object descriptions that you provide yourself, the permanent store is filled automatically by the SDK from the Object API.
### Static Objects
The static object directory is a mechanism that is mostly intended for testing. It allows you to provide object descriptions yourself, for example as fixtures in your test suite, so that your code can be tested without connecting to CloudObjects Core, or with objects that differ from or do not yet exist in CloudObjects Core. It should usually not be configured in production.
To enable it, set the `static_object_directory` option to a path on the filesystem. Object descriptions are read from `<directory>/<namespace>/<path of COID>/object.jsonld`, which is the same layout used by the fallback and permanent stores. For example, the object `coid://example.com/MyObject` is read from `<directory>/example.com/MyObject/object.jsonld`, and the namespace object `coid://example.com` itself is read from `<directory>/example.com/object.jsonld`. Each file must contain the object description in JSON-LD format, with an `@id` that matches the COID.
```json
{
"@id": "coid://example.com/MyObject",
"http://www.w3.org/2000/01/rdf-schema#label": "My Object"
}
```
The static object directory is consulted before the external cache, the permanent store and the API. Objects that are not found in the directory are retrieved as usual, so you can override only some objects and let the SDK fetch the rest:
```php
use CloudObjects\SDK\ObjectRetriever;
$retriever = new ObjectRetriever([
'static_object_directory' => __DIR__.'/fixtures/objects',
]);
```
Static objects are only used by `getObjectNode()` and the methods built on it; methods that fetch multiple objects from a namespace, such as `fetchAllObjectsInNamespace()`, always use the API. The SDK never writes to the static object directory, so it is not necessary to specify a scope; any COIDs will be considered for the static store.
In earlier versions of the SDK, this option was called `static_config_path`. The old name is deprecated but still supported.