joaoolival/laravel-blog-engine
Composer 安装命令:
composer require joaoolival/laravel-blog-engine
包简介
A Laravel package that provides the core backend logic for blogs, including post management, publishing workflows, slugs, tags, categories, and authoring. Frontend framework-agnostic and UI-independent.
README 文档
README
A blog engine for Laravel with Filament admin panel integration. Manage posts, authors, and categories with automatic responsive image optimization.
Requirements
- PHP 8.3+
- Laravel 12 or 13
- Filament 5
- Spatie Laravel Media Library 11
Installation
composer require joaoolival/laravel-blog-engine php artisan blog-engine:install php artisan storage:link
Configuration
Publish the configuration file to customize resource labels, navigation, and icons:
php artisan vendor:publish --tag="laravel-blog-engine-config"
You can customize the following for Posts, Authors, and Categories in config/laravel-blog-engine.php:
label&plural_label: Custom names for resources.navigation_label: Label shown in the sidebar.navigation_group: Group resources under a specific sidebar group (default: "Blog").navigation_sort: Order in the navigation.navigation_icon: Heroicon name (e.g.,heroicon-o-pencil) for the sidebar icon.
Authorization
To restrict access to blog resources, simply create Policies for the models (BlogPost, BlogAuthor, BlogCategory). Filament will automatically detect and enforce them.
This allows you to define granular permissions for who can view, create, update, delete, and restore resources.
php artisan make:policy BlogPostPolicy --model=\Joaoolival\LaravelBlogEngine\Models\BlogPost
Then register them in your application's AuthServiceProvider (or AppServiceProvider in newer Laravel versions).
For more details, see the Filament Resource Authorization documentation.
Basic Usage
use Joaoolival\LaravelBlogEngine\Facades\Blog; $posts = Blog::getPublishedPosts(perPage: 12); $post = Blog::getPostBySlug('my-post'); $authors = Blog::getAllAuthors(); $categories = Blog::getAllCategories();
Content & Responsive Images
Post content is stored as an HTML string (database longtext). When building APIs, use the provided HTTP Resources to automatically render content with responsive images:
use Joaoolival\LaravelBlogEngine\Http\Resources\Posts\BlogPostResource; return new BlogPostResource($post);
The resource transforms the content HTML, finding image tags with data-id and replacing them with:
- WebP conversion
srcsetattributes for responsive loading- Lazy loading and async decoding
Note: Accessing
$post->contentdirectly returns the raw HTML with custom attributes. UseBlogPostResourcefor fully rendered HTML with responsive images.
Facade Methods
| Method | Description |
|---|---|
getPublishedPosts(?int $perPage) |
Published posts (paginated or collection) |
getPostBySlug(string $slug) |
Single post by slug |
getRecentPosts(int $limit = 5) |
Most recent posts (for sidebars) |
getRelatedPosts(BlogPost $post, int $limit = 4) |
Related posts by category/tags |
searchPosts(string $query, ?int $perPage) |
Search posts by title/excerpt/content |
getAllAuthors() |
All visible authors |
getAuthorWithPosts(string $slug, ?int $perPage) |
Author with their posts |
getAllCategories() |
All visible categories |
getCategoryWithPosts(string $slug, ?int $perPage) |
Category with its posts |
Models
BlogPost
| Attribute | Type | Description |
|---|---|---|
title |
string |
Post title |
slug |
string |
URL-friendly identifier |
excerpt |
string | null |
Short summary |
content |
string | null |
HTML content (longtext) |
tags |
array | null |
Post tags |
is_visible |
bool |
Visibility flag |
published_at |
Carbon | null |
Publish date |
Scopes:
BlogPost::whereIsPublished()->get(); BlogPost::whereIsDraft()->get(); BlogPost::whereIsVisible()->get();
BlogAuthor
| Attribute | Type |
|---|---|
name, slug, email |
string |
bio, github_handle, twitter_handle |
string|null |
BlogCategory
| Attribute | Type |
|---|---|
name, slug |
string |
description, seo_title, seo_description |
string|null |
is_visible |
bool |
Admin Panel
Access the Filament admin at /admin:
/admin/blog-posts/admin/blog-authors/admin/blog-categories
Responsive Images
This package uses Spatie Media Library for image handling. Images are automatically converted to WebP with responsive variants.
For background processing, install Laravel Horizon:
composer require laravel/horizon php artisan horizon:install php artisan horizon
Generating Demo Content
Quickly populate your blog with dummy content using the blog:generate command:
php artisan blog:generate
This will prompt for the number of authors, categories, and posts to create (defaults: 1, 1, 12).
You can also pass options directly:
php artisan blog:generate --authors=3 --categories=5 --posts=50
Testing
composer test
Credits
Support
If you encounter any issues or have questions, please open an issue on GitHub.
License
MIT. See LICENSE.md.
joaoolival/laravel-blog-engine 适用场景与选型建议
joaoolival/laravel-blog-engine 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 197 次下载、GitHub Stars 达 3, 最近一次更新时间为 2026 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「joaoolival」 「laravel-blog-engine」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 joaoolival/laravel-blog-engine 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 joaoolival/laravel-blog-engine 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 joaoolival/laravel-blog-engine 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
Turn any PDF into a Pingen-ready A4 letter (generated address cover page + A4 normalisation + safe margins) and send it through the Pingen print & mail API. Laravel-first.
统计信息
- 总下载量: 197
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-08