dunglas / solid-client-php
Solid client implementation for PHP
Fund package maintenance!
dunglas
Requires
- php: >=8.1
- easyrdf/easyrdf: ^1.1
- jumbojett/openid-connect-php: ^0.9.10
- ml/json-ld: ^1.2
- symfony/http-client: ^6.0
- web-token/jwt-checker: ^3.0
- web-token/jwt-core: ^3.0
- web-token/jwt-key-mgmt: ^3.0
- web-token/jwt-signature: ^3.0
- web-token/jwt-signature-algorithm-ecdsa: ^3.0
- web-token/jwt-signature-algorithm-hmac: ^3.0
- web-token/jwt-signature-algorithm-rsa: ^3.0
Requires (Dev)
- symfony/browser-kit: ^6.0
- symfony/console: ^6.0
- symfony/css-selector: ^6.0
- symfony/debug-bundle: ^6.0
- symfony/dependency-injection: ^6.0
- symfony/form: ^6.0
- symfony/framework-bundle: ^6.0
- symfony/http-foundation: ^6.0
- symfony/phpunit-bridge: ^6.0
- symfony/routing: ^6.0
- symfony/security-bundle: ^6.0
- symfony/security-core: ^6.0
- symfony/stopwatch: ^6.0
- symfony/twig-bundle: ^6.0
- symfony/validator: ^6.0
- symfony/web-profiler-bundle: ^6.0
- vimeo/psalm: ^5.12
README
Re-decentralizing the web
Solid (derived from "social linked data") is a proposed set of conventions and tools for building decentralized Web applications based on Linked Data principles.
This repository contains a PHP library for accessing data and managing permissions on data stored in a Solid Pod It also a contains a Symfony bundle to easily build Solid applications with the Symfony and API Platform frameworks.
Take a look at the presentation of this library at the SymfonyLive Paris 2022 conference.
Install
composer require dunglas/solid-client-php
If you use Symfony or API Platform, the bundle and the corresponding recipe will be installed automatically.
Example
<?php use Dunglas\PhpSolidClient\SolidClientFactory; use Dunglas\PhpSolidClient\OidcClient; use Symfony\Component\HttpClient\HttpClient; $solidClientFactory = new SolidClientFactory(HttpClient::create()); // Create an anonymous Solid client $anonymousSolidClient = $solidClientFactory->create(); // Fetch the WebID profile of a user $profile = $anonymousSolidClient->getProfile('https://example.com/your/webid'); // Fetch the OIDC issuer for a user $oidcIssuer = $anonymousSolidClient->getOidcIssuer('https://example.com/your/webid'); // Create a Solid OIDC client for this user $oidcClient = new OidcClient($oidcIssuer); // Register the OIDC client dynamically $oidcClient->register(); // Authenticate the user $oidcClient->authenticate(); // At this point you may want to save $oidcClient in the session // The user will be redirected to the OIDC server to log in // Create a Solid client generating DPoP access tokens for the logged-in user $loggedSolidClient = $solidClientFactory->create($oidcClient); // Create a new container $containerResponse = $loggedSolidClient->createContainer('https://mypod.example.com', 'blog'); $container = $containerResponse->getContent(); // Post a new note $apiPlatformResponse = $loggedSolidClient->post('https://mypod.example.com/blog', 'api-platform-conference', <<<TTL @prefix as: <http://www.w3.org/ns/activitystreams#>. <> a as:Note; as:content "Going to API Platform Conference". TTL ); $apiPlatformCon = $apiPlatformResponse->getContent(); // Fetch an existing note $symfonyLiveResponse = $loggedSolidClient->get('https://mypod.example.com/blog/symfony-live'); $symfonyLive = $symfonyLiveResponse->getContent(); // Logout $oidcClient->signOut($oidcClient->getIdToken());
Features
- Standalone PHP library
- Symfony Bundle
- OAuth/OIDC authenticator
- Solid client as a service
Authentication
- Modern and Fully featured OAuth and OpenID Connect client (work even without Solid, extends
jumbojett/openid-connect-php
) - Solid OIDC
Identity
Reading and Writing Resources
- Linked Data Platform
- Solid HTTPS REST API (uses Symfony HttpClient)
- Solid Content Representation (delegated to EasyRDF)
Not Implemented Yet
- OAuth Client ID
- Solid OIDC "Request Flow" (currently not supported by mainstream Solid servers)
- Web Access Control
- WebSockets API
- Social Web App Protocols
- WebID-TLS (not supported anymore in web browsers)
- Symfony Bundle
- Redirect after login