Code Monkey home page Code Monkey logo

solid-client-php's Introduction

Solid Client PHP

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

Identity

Reading and Writing Resources

Not Implemented Yet

solid-client-php's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.