Fetching and transforming data from API to JSON-LD using spatie/schema-org
-
Clone the repository:
git clone https://github.com/helsingborg-stad/schema.org-transformer.git
-
Install dependencies:
composer install
To run the router script, use the following command:
Usage: php router.php
Input settings
--source <file|url> Input file or URL
--sourceheaders <headers> Comma separated HTTP headers when source is a URL
Output settings
--output <file|url> Output file or URL
--outputheaders <headers> Comma separated HTTP headers when output is a URL
--outputformat <json|jsonl> Output format
Transformation settings
--transform <jobposting> Name of transform to apply
OAuth authentication parameters (Applicable for source only)
--authpath <url> URL of token service
--authclientid <string> Client id
--authclientsecret <string> Client secret
Typesense connection (optional, used for some transforms)
--typesense_apikey <string> Typesense API key
--typesense_host <string> Typesense host
--typesense_port <int> Typesense port (default 443)Example:
php router.php --source https://reachmee --output /tmp/output.json --transform jobposting| Transform | Typesense data for joins |
|---|---|
| jobposting | |
| stratsys | |
| wp_legacy_event | |
| wp_release_event | |
| wp_exhibition_event | |
| elementary_school | events collection |
| pre_school | events collection |
You can add additional transforms to the Transforms folder.
- Fork the repository.
- Create a new branch (
git checkout -b feature-name). - Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature-name). - Create a new pull request.
This project is licensed under the MIT License.