julienbourdeau/laravel-ghost-connector
Composer 安装命令:
composer require julienbourdeau/laravel-ghost-connector
包简介
Use your Ghost posts as if they were Eloquent models from your DB. Thanks to Sushi and the Ghost API!
README 文档
README
This package retrieve content from a Ghost blog and make it available as a regular model using Sushi.
The content will be kept in memory and reused anytime you call the model builder. It's not shared between requests.
I wrote this package because I built my custom blog on Laravel, with Laravel Nova. I like it for long articles but for journaling, I found the writing experience not so nice. With this package, I write in Ghost admin, but the content is still published via Laravel. 🏄♂️
Installation
You can install the package via composer:
composer require julienbourdeau/laravel-ghost-connector
Add your Ghost credentials in our .env.
GHOST_API_URL=http://localhost:2369 GHOST_CONTENT_KEY=2b3934d798ccce67daacdc8adb
Usage
Here are a few simple example how you'd typically use this package. The following code will make one single HTTP call to Ghost.
Post::count(); Post::all()->map(function($x) { dump($x->title); }); Post::where('featured', true)->get();
@foreach (Post::all() as $post) <h2>{{ $post->title }}</h2> <p>{{ nl2br($post->excerpt) }}</p> <hr> @endforeach
Ghost API
When retrieving the posts from Ghost, the package will include tags and authors.
Content is also casted, using the regular $casts Model feature.
Example
This is the API response and the following is Post::first()->toArray().
array:34 [
"id" => "5e80568dc50444aef65bea46"
"uuid" => "97f42901-6b26-4a61-9ec6-96852d05e0f3"
"title" => "Welcome to Ghost"
"slug" => "welcome"
"html" => "<h2 id="a-few-things-you-should-know"><strong>A few things you should know</strong></h2><ol><li>Ghost is
designed for ambitious ... Blah blah blah"
"comment_id" => "5e80568dc50444aef65bea46"
"feature_image" => "https://static.ghost.org/v3.0.0/images/welcome-to-ghost.png"
"featured" => false
"visibility" => "public"
"send_email_when_published" => false
"created_at" => "2020-03-29T08:04:29.000000Z"
"updated_at" => "2020-03-29T08:04:29.000000Z"
"published_at" => "2020-03-29T08:04:35.000000Z"
"custom_excerpt" => """
Welcome, it's great to have you here.\n
We know that first impressions are important, so we've populated your new site with some initial getting started posts that will help you get familiar with everything in no time.
"""
"codeinjection_head" => null
"codeinjection_foot" => null
"custom_template" => null
"canonical_url" => null
"authors" => array:1 [
0 => array:13 [
"id" => "5951f5fca366002ebd5dbef7"
"name" => "Ghost"
"slug" => "ghost"
"profile_image" => "https://static.ghost.org/v3.0.0/images/ghost.png"
"cover_image" => null
"bio" => "You can delete this user to remove all the welcome posts"
"website" => "https://ghost.org"
"location" => "The Internet"
"facebook" => "ghost"
"twitter" => "ghost"
"meta_title" => null
"meta_description" => null
"url" => "http://localhost:2369/author/ghost/"
]
]
"tags" => array:1 [
0 => array:9 [
"id" => "5e80568cc50444aef65be9e6"
"name" => "Getting Started"
"slug" => "getting-started"
"description" => null
"feature_image" => null
"visibility" => "public"
"meta_title" => null
"meta_description" => null
"url" => "http://localhost:2369/tag/getting-started/"
]
]
"primary_author" => array:13 [
"id" => "5951f5fca366002ebd5dbef7"
"name" => "Ghost"
"slug" => "ghost"
"profile_image" => "https://static.ghost.org/v3.0.0/images/ghost.png"
"cover_image" => null
"bio" => "You can delete this user to remove all the welcome posts"
"website" => "https://ghost.org"
"location" => "The Internet"
"facebook" => "ghost"
"twitter" => "ghost"
"meta_title" => null
"meta_description" => null
"url" => "http://localhost:2369/author/ghost/"
]
"primary_tag" => array:9 [
"id" => "5e80568cc50444aef65be9e6"
"name" => "Getting Started"
"slug" => "getting-started"
"description" => null
"feature_image" => null
"visibility" => "public"
"meta_title" => null
"meta_description" => null
"url" => "http://localhost:2369/tag/getting-started/"
]
"url" => "http://localhost:2369/welcome/"
"excerpt" => """
Welcome, it's great to have you here.\n
We know that first impressions are important, so we've populated your new site with some initial getting started posts that will help you get familiar with everything in no time.
"""
"reading_time" => 1
"og_image" => null
"og_title" => null
"og_description" => null
"twitter_image" => null
"twitter_title" => null
"twitter_description" => null
"meta_title" => null
"meta_description" => null
"email_subject" => null
]
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 julien@sigerr.org instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.
julienbourdeau/laravel-ghost-connector 适用场景与选型建议
julienbourdeau/laravel-ghost-connector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「julienbourdeau」 「laravel-ghost-connector」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 julienbourdeau/laravel-ghost-connector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 julienbourdeau/laravel-ghost-connector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 julienbourdeau/laravel-ghost-connector 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-04