1. Go to this page and download the library: Download igorsgm/laravel-ghost 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/ */
igorsgm / laravel-ghost example snippets
// Using the Facade (recommended), which will take the variables from the ghost.php config file
$contentApi = Ghost::content();
$response = $contentApi->posts()->all();
// Or you can set the variables manually
$contentApi = Ghost::content([
'key' => '22444f78447824223cefc48062',
'domain' => 'https://demo.ghost.io',
'version' => 4
]);
$response = $contentApi->posts()->all();
$posts = $response->data;
$meta = $response->meta;
// All resources returned as SuccessResponse (or ErrorResponse)
Ghost::content()->posts()->all();
Ghost::content()->authors()->all();
Ghost::content()->tags()->all();
Ghost::content()->pages()->all();
Ghost::content()->settings()->all();
Ghost::content()->tiers()->all();
// Retrieve a single resource by slug
Ghost::content()->posts()->fromSlug('welcome');
// Retrieve first resource item
Ghost::content()->posts()->first();
// Retrieve a single resource by id
Ghost::content()->posts()->find('6285dbba44c5d85187a074ba');
// Get paginated resources
Ghost::content()->posts()->paginate();
$response = Ghost::content()->posts()->paginate(15);
$posts = $response->data;
$meta = $response->meta;
// Browse between pages
$response->getNextPage();
$response->getPreviousPage();
// Create post with mobiledoc source
Ghost::admin()->posts()->create([
'title' => 'My Test Post',
'mobiledoc' => '{"version":"0.3.1","atoms":[],"cards":[],"markups":[],"sections":[[1,"p",[[0,[],0,"My post content. Work in progress..."]]]]}',
'status' => 'published',
]);
// Create post with HTML source
Ghost::admin()->posts()->source('html')->create([
'title' => 'My Test Post 2',
'html' => '<p>My post content. Work in progress...</p>',
'status' => 'published',
]);
// Update resource with mobiledoc source
// The updated_at field is