PHP code example of pdsinterop / solid-crud

1. Go to this page and download the library: Download pdsinterop/solid-crud library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pdsinterop / solid-crud example snippets


$formats = new \Pdsinterop\Rdf\Formats();

$rdfAdapter = new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf(
    new \League\Flysystem\Adapter\Local('/path/to/data'),
    new \EasyRdf_Graph(),
    $formats,
    'https://example.com/'
);

$filesystem = new \League\Flysystem\Filesystem($rdfAdapter);

$filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats));


$server = new \Pdsinterop\Solid\Resources\Server($filesystem, new \Laminas\Diactoros\Response());

$request = \Laminas\Diactoros\ServerRequestFactory::fromGlobals(
    $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES
);

$response = $server->respondToRequest($request);

    $request = $request->withUri($request->getUri()->withPath($changedPath));

    $request = $request->withMethod('PUT');



/*/ Create the filesystem /*/
$formats = new \Pdsinterop\Rdf\Formats();

$rdfAdapter = new \Pdsinterop\Rdf\Flysystem\Adapter\Rdf(
    new \League\Flysystem\Adapter\Local('/path/to/data'),
    new \EasyRdf_Graph(),
    $formats,
    'https://example.com/'
);

$filesystem = new \League\Flysystem\Filesystem($rdfAdapter);

$filesystem->addPlugin(new \Pdsinterop\Rdf\Flysystem\Plugin\AsMime($formats));

/*/ Create the server /*/
$server = new \Pdsinterop\Solid\Resources\Server($filesystem, new \Laminas\Diactoros\Response());

/*/ Create a PSR-7 Request object /*/
$request = \Laminas\Diactoros\ServerRequestFactory::fromGlobals(
    $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES
);

/*/ Remove the `/data` prefix from the path /*/
$changedPath = substr($request->getUri()->getPath(), 5);
$request = $request->withUri($request->getUri()->withPath($changedPath));

/*/ Handle the request /*/
$response = $server->respondToRequest($request);