承接 igorsgm/laravel-ghost 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

igorsgm/laravel-ghost

Composer 安装命令:

composer require igorsgm/laravel-ghost

包简介

👻• A Laravel wrapper that allows you to access Ghost APIs (Content & Admin). Access, create and manage your Ghost content from you app!

README 文档

README

Laravel Ghost

A Laravel wrapper that allows you to access Ghost APIs (Content & Admin). Access, create and manage your Ghost content from you app!

Latest Version on Packagist Build Status Tests Coverage Quality Score Total Downloads

Installation

You can install the package via composer:

composer require igorsgm/laravel-ghost

You can publish the config file with:

php artisan vendor:publish --provider="Igorsgm\Ghost\GhostServiceProvider" --tag="ghost-config"

Usage

Define Ghost API credentials at ghost.php config or in your .env file. i.e.:

GHOST_ADMIN_DOMAIN=https://demo.ghost.io
GHOST_CONTENT_API_KEY=22444f78447824223cefc48062
GHOST_ADMIN_API_KEY=foo:bar

Content API

1) General Usage

// 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;

The Content API for posts, pages, tags, authors, settings, tiers are similiar and can be used with the following methods:

// 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();

Single resource returned as Post, Author, Tag, Page or Tier

// 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');

Paginations

// 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();

Build your request

Valid for both: Ghost::content() and Ghost::admin() APIs

Ghost::content()->posts()
    ->include('authors', 'tags') // https://ghost.org/docs/content-api/#include
    ->fields('title', 'slug', 'html') // https://ghost.org/docs/content-api/#fields
    ->formats('html') // https://ghost.org/docs/content-api/#formats
    ->filter('author:john+featured:true') // https://ghost.org/docs/content-api/#filtering
    ->limit(20) // https://ghost.org/docs/content-api/#limit
    ->page(2) // https://ghost.org/docs/content-api/#page
    ->orderBy('title', 'DESC') // https://ghost.org/docs/content-api/#order
    ->get();

Admin API

  • All ContentAPI methods related to Post, Author, Tag, Page or Tier are also available in the Admin API.
Resource Methods
->posts() get, create, update, delete
->pages() get, create, update, delete
->tags() get, create, update, delete
->tiers() get, create, update, delete
->offers() get, create, update
->members() get, create, update
->users() get
->images() upload
->themes() upload, activate
->site() get
->webhooks() create, update, delete

(Admin) Posts, Pages, Tags, Tiers, Offers, Members, Users, Webhooks

The consume of these Admin APIs are similar and can be used with the following methods:

// 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 required as it is used to handle collision detection, and ensure you’re not overwriting more recent updates.
// It is recommended to perform a GET request to fetch the latest data before updating a resource.
$post = Ghost::admin()->posts()->find($id);
Ghost::admin()->posts()->source('html')->update($id, [
    'title' => 'My New Title',
    'html' => '<p>My post content updated. Work in progress...</p>',
    'updated_at' => $post->updatedAt,
]);

// Delete resource by ID
Ghost::admin()->posts()->delete('6285dbba44c5d85187a074ba');

(Admin) Images, Themes

// Upload image
$imagePathOrUrl = 'https://picsum.photos/200';
$response = Ghost::admin()->images()->upload($imagePathOrUrl);

// Upload theme (.zip)
$zipPathOrUrl = 'https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-zip-file.zip';
$response = Ghost::admin()->themes()->upload($zipPathOrUrl);

// Activate a theme
Ghost::admin()->themes()->activate('theme-name');

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email igor.sgm@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

igorsgm/laravel-ghost 适用场景与选型建议

igorsgm/laravel-ghost 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 881 次下载、GitHub Stars 达 12, 最近一次更新时间为 2022 年 06 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「blog」 「cms」 「laravel」 「Ghost」 「igorsgm」 「laravel-ghost」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 igorsgm/laravel-ghost 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 igorsgm/laravel-ghost 我们能提供哪些服务?
定制开发 / 二次开发

基于 igorsgm/laravel-ghost 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 881
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-06