PHP code example of dromedar-design / laravel-prismic

1. Go to this page and download the library: Download dromedar-design/laravel-prismic 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/ */

    

dromedar-design / laravel-prismic example snippets


'connections' => [

    'prismic' => [
        'driver' => 'prismic',
        'database' => 'https://XXX.cdn.prismic.io/api/v2',
        'cache' => false,
    ],
    
    // other connections
],



namespace App;

use DromedarDesign\Prismic\Model;

class Post extends Model
{
    //
}


$post = \App\Post::first();

$title = $post->title; // By default it returns the html output

// Output: <h1>Hello, this is title</h1>

$title = $post->title->text;

// Output: Hello, this is title

$post->setPrismicMode('raw');
$title = $post->title;

/** Output:
 *  [
 *      {
 *          "type": "heading1",
 *          "text": "Hello, this is title",
 *          "spans": []
 *      }
 *  ]
 */