dknx01 / rsl-lib
RSL generation lib
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/dknx01/rsl-lib
Requires
- php: >=8.4
- ext-dom: *
Requires (Dev)
- ergebnis/composer-normalize: ^2.48
- friendsofphp/php-cs-fixer: ^3.92
- phpspec/prophecy: ^1.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.0
- roave/security-advisories: dev-latest
README
This is a library for creating an XML string of the RSL standard to be used in your application. It has only dependencies for testing purpose and for PHP (DOM extension).
RSL = Really Simple Licensing
The open content licensing standard for the AI-first Internet
RSL is an open, XML-based document format for defining machine-readable licensing terms for digital assets, including web pages, books, videos, images, and proprietary datasets.
Website: https://rslstandard.org/guide/what-is-rsl
Installation:
composer require dknx01/rsl-lib
Usage
You can have a look into the test/Integration/RslBuilderTest class.
The result is like the test example under tests/Integration/expected.xml.
This is an example with all fields filled:
$builder = new RslBuilder(); $content = new Content('/', 'https://api.example.com'); $content->addLicense( new License( permits: [ Usage::new(UsageAssets::ALL), User::new(UserAssets::EDUCATION), Geo::new(['EU']), ], prohibits: [ \Dknx01\RslLib\Elements\Probihits\User::new(UserAssets::EDUCATION), \Dknx01\RslLib\Elements\Probihits\Usage::new(UsageAssets::AI_INPUT), \Dknx01\RslLib\Elements\Probihits\Geo::new(['AF']), ], payments: [ PurchasePayment::new([ new Amount('EUR', '49.00'), new Accepts('{"json": true}'), new Standard('https://creativecommons.org/licenses/by/4.0/'), new Custom('https://creativecommons.org/licenses/by/4.0/'), ]), SubscriptionPayment::new([new Amount('EUR', '49.00')]), TrainingPayment::new([new Amount('EUR', '49.00')]), CrawlPayment::new([new Amount('EUR', '49.00'), new Accepts('{"json": true}')]), UsePayment::new([new Amount('EUR', '49.00')]), ContributionPayment::new([new Amount('EUR', '49.00')]), AttributionPayment::new([new Amount('EUR', '49.00')]), FreePayment::new([new Amount('EUR', '0.00')]), ], legals: [ Warranty::new('ownership authority no-infringement'), Disclaimer::new('as-is no-liability'), Attestation::new(true), Contact::new('https://example.com/contact'), Proof::new('https://blockscan.example/tx/0x9aBcD123... '), ] ) ) ->addAlternate(new Alternate('/exports/site-2025-10-20.warc', 'application/warc')) ->addAlternate(new Alternate('/exports/site-2025-10-20.json', 'application/json')) ->addSchema(new Schema(value: '/metadata/books/moby-dick.jsonld')) ->addCopyright(new Copyright(value: 'Example Media LLC', type: 'organization', contactUrl: 'https://example.com/contact.html')) ->addTerms(new Terms('https://example.com/legal/data-terms.html')); $builder->addContent($content); $result = $builder->getXml();
TO see which parameters are available and needed, have a look on the RSL website. The naming is the same for the elements.
For example:
addCopyright(new Copyright(value: 'Example Media LLC', type: 'organization', contactUrl: 'https://example.com/contact.html')) is not needed if you don't provide this information
ToDo
[] improve test coverage [] add more examples