PHP code example of netglue / prismic-doctype-client

1. Go to this page and download the library: Download netglue/prismic-doctype-client 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/ */

    

netglue / prismic-doctype-client example snippets



use Prismic\DocumentType\BaseClient;

$client = new BaseClient(
    'some-token',
    'my-repository-name',
    $httpClient,     // \Psr\Http\Client\ClientInterface
    $requestFactory, // \Psr\Http\Message\RequestFactoryInterface
    $uriFactory,     // \Psr\Http\Message\UriFactoryInterface
    $streamFactory   // \Psr\Http\Message\StreamFactoryInterface
)

use Prismic\DocumentType\Client;
use Prismic\DocumentType\Definition;

assert($client instanceof Client);

// Insert or update a document type:
$client->saveDefinition(Definition::new(
    id: 'my-type',
    label: 'Some Label',
    repeatable: true,
    active: true,
    json: $someJsonPayloadAsAString,
));

// Fetch all remote document type defs
$client->fetchAllDefinitions();

// Fetch a single definition
$client->getDefinition('some-type');

// Delete a document type definition
$client->deleteDefinition('some-type');

use Prismic\DocumentType\SharedSlice;use Prismic\DocumentType\SharedSliceManagementClient;

assert($client instanceof SharedSliceManagementClient);

// Insert or update a slice def:
$client->saveSharedSlice(SharedSlice::new(
    id: 'some-slice-id',
    json: $someJsonPayloadAsAString, 
));

// Fetch all slice defs:
$client->fetchAllSharedSlices();

// Fetch one slice def:
$client->getSharedSlice('whatever');

// Delete a shared slice:
$client->deleteSharedSlice('some-id');