PHPackages                             jeffersongoncalves/laravel-knowledge-base - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. jeffersongoncalves/laravel-knowledge-base

ActiveLibrary[Search &amp; Filtering](/categories/search)

jeffersongoncalves/laravel-knowledge-base
=========================================

A Laravel package for building knowledge bases with articles, categories, versioning, and feedback

v1.0.2(2mo ago)41031MITPHPPHP ^8.2CI passing

Since Feb 18Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/jeffersongoncalves/laravel-knowledge-base)[ Packagist](https://packagist.org/packages/jeffersongoncalves/laravel-knowledge-base)[ Docs](https://github.com/jeffersongoncalves/laravel-knowledge-base)[ RSS](/packages/jeffersongoncalves-laravel-knowledge-base/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (11)Versions (5)Used By (1)

[![Laravel Knowledge Base](https://raw.githubusercontent.com/jeffersongoncalves/laravel-knowledge-base/main/art/jeffersongoncalves-laravel-knowledge-base.png)](https://raw.githubusercontent.com/jeffersongoncalves/laravel-knowledge-base/main/art/jeffersongoncalves-laravel-knowledge-base.png)

Laravel Knowledge Base
======================

[](#laravel-knowledge-base)

A Laravel package for building knowledge bases with articles, categories, versioning, feedback, and search.

Features
--------

[](#features)

- **Article Management** — Create, update, publish, archive, and soft-delete articles with UUID and slug routing
- **Hierarchical Categories** — Nested parent/child categories with ordering and activation control
- **Article Versioning** — Automatic version history tracking with editor attribution and change notes
- **User Feedback** — Helpful/not helpful voting with optional comments, supports authenticated and anonymous users
- **Related Articles** — Many-to-many article relationships with sort ordering
- **Full-Text Search** — Database-powered search across published articles by title and content
- **SEO Fields** — Built-in SEO title, description, and keywords per article
- **Customizable Models** — Override any model via config while maintaining contract compliance
- **Table Prefix** — Configurable table prefix to avoid naming collisions (default: `kb_`)
- **Translations** — English and Brazilian Portuguese out of the box

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11+

Installation
------------

[](#installation)

```
composer require jeffersongoncalves/laravel-knowledge-base
```

Publish and run migrations:

```
php artisan vendor:publish --tag="knowledge-base-migrations"
php artisan migrate
```

Publish the config (optional):

```
php artisan vendor:publish --tag="knowledge-base-config"
```

Configuration
-------------

[](#configuration)

The config file (`config/knowledge-base.php`) covers:

### Table Prefix

[](#table-prefix)

```
'table_prefix' => 'kb_',
```

Set to `null` to use table names without a prefix.

### Custom Models

[](#custom-models)

Override any model to extend the default behavior. Custom models must implement the corresponding contract:

```
'models' => [
    'article' => \App\Models\Article::class,
    'category' => \App\Models\Category::class,
    'article_version' => \App\Models\ArticleVersion::class,
    'article_feedback' => \App\Models\ArticleFeedback::class,
    'article_relation' => \App\Models\ArticleRelation::class,
],
```

### Knowledge Base Settings

[](#knowledge-base-settings)

```
'default_visibility' => 'public',   // default visibility for new articles
'versioning_enabled' => true,       // track article version history
'feedback_enabled' => true,         // allow user feedback
'track_views' => true,              // track article view counts
```

### Search

[](#search)

```
'search_engine' => 'database',      // search engine type
'search_results_limit' => 20,       // max results per search
```

Usage
-----

[](#usage)

### Using the Service

[](#using-the-service)

The `KnowledgeBaseService` is the recommended way to interact with the knowledge base:

```
use JeffersonGoncalves\KnowledgeBase\Services\KnowledgeBaseService;

$service = app(KnowledgeBaseService::class);
```

### Creating Categories

[](#creating-categories)

```
// Auto-generates slug from name
$category = $service->createCategory([
    'name' => 'Getting Started',
]);

// With custom slug and parent
$child = $service->createCategory([
    'name' => 'Installation',
    'slug' => 'installation-guide',
    'parent_id' => $category->id,
    'description' => 'How to install the application',
    'icon' => 'heroicon-o-wrench',
    'sort_order' => 1,
]);

// Update
$service->updateCategory($category, ['name' => 'Quick Start']);

// Delete (soft delete)
$service->deleteCategory($category);
```

### Creating Articles

[](#creating-articles)

```
$article = $service->createArticle([
    'category_id' => $category->id,
    'title' => 'How to Install',
    'slug' => 'how-to-install',
    'content' => 'Step 1: Run composer require...',
    'excerpt' => 'Quick installation guide.',
    'visibility' => 'public',
    'seo_title' => 'Installation Guide - My App',
    'seo_description' => 'Learn how to install My App step by step.',
    'seo_keywords' => 'install, setup, getting started',
    'metadata' => ['difficulty' => 'beginner'],
], $author); // $author is any Eloquent Model (User, Admin, etc.)
```

This automatically:

- Generates a UUID
- Creates version 1 (when versioning enabled)
- Dispatches `ArticleCreated` event

### Updating Articles

[](#updating-articles)

```
$updated = $service->updateArticle($article, [
    'title' => 'How to Install (Updated)',
    'content' => 'Updated installation steps...',
], $editor, 'Fixed outdated instructions');
```

When versioning is enabled, this creates a new version entry with the editor and change notes.

### Publishing &amp; Archiving

[](#publishing--archiving)

```
// Publish — sets status to Published, sets published_at, dispatches ArticlePublished
$service->publishArticle($article);

// Archive — sets status to Archived
$service->archiveArticle($article);

// Delete — soft deletes
$service->deleteArticle($article);
```

### Feedback

[](#feedback)

```
// Authenticated helpful feedback
$service->addFeedback($article, true, $user, 'Very clear, thank you!', '127.0.0.1');

// Anonymous not-helpful feedback
$service->addFeedback($article, false, null, 'Needs more examples');

// Anonymous without comment
$service->addFeedback($article, true);
```

Feedback automatically increments `helpful_count` or `not_helpful_count` on the article and dispatches `ArticleFeedbackReceived`.

### Search

[](#search-1)

```
// Basic search (only published articles)
$results = $service->search('installation');

// With filters
$results = $service->search('installation', [
    'category_id' => 1,
    'visibility' => 'public',
    'limit' => 10,
]);
```

Results are ordered by `view_count` descending (most popular first).

### Using Models Directly

[](#using-models-directly)

For queries outside the service, use `ModelResolver`:

```
use JeffersonGoncalves\KnowledgeBase\Support\ModelResolver;

$articleClass = ModelResolver::article();
$categoryClass = ModelResolver::category();

// Article scopes
$published = $articleClass::published()->get();
$drafts = $articleClass::draft()->get();
$archived = $articleClass::archived()->get();
$internal = $articleClass::byVisibility(ArticleVisibility::Internal)->get();

// Category scopes
$active = $categoryClass::active()->get();
$roots = $categoryClass::root()->get();
$ordered = $categoryClass::ordered()->get();
$tree = $categoryClass::active()->root()->ordered()->get();

// Relationships
$article->category;
$article->author;
$article->versions;
$article->feedback;
$article->relatedArticles;

$category->parent;
$category->children;
$category->articles;

// View tracking
$article->incrementViewCount();
```

### Extending Models

[](#extending-models)

Create custom models that implement the required contract:

```
namespace App\Models;

use JeffersonGoncalves\KnowledgeBase\Models\Article as BaseArticle;
use JeffersonGoncalves\KnowledgeBase\Models\Contracts\ArticleContract;

class Article extends BaseArticle implements ArticleContract
{
    // Add custom relationships, scopes, methods...

    public function comments()
    {
        return $this->hasMany(Comment::class);
    }
}
```

Then update the config:

```
// config/knowledge-base.php
'models' => [
    'article' => \App\Models\Article::class,
    // ...
],
```

Events
------

[](#events)

EventPayloadWhen`ArticleCreated``$article`After article creation via service`ArticlePublished``$article`After publishing via service`ArticleFeedbackReceived``$article`, `$feedback`After feedback submissionListen to events in your `EventServiceProvider` or with listeners:

```
use JeffersonGoncalves\KnowledgeBase\Events\ArticlePublished;

class SendArticleNotification
{
    public function handle(ArticlePublished $event): void
    {
        // Notify subscribers about the new article
        $article = $event->article;
    }
}
```

Enums
-----

[](#enums)

### ArticleStatus

[](#articlestatus)

ValueLabel (en)Label (pt\_BR)`draft`DraftRascunho`published`PublishedPublicado`archived`ArchivedArquivado### ArticleVisibility

[](#articlevisibility)

ValueLabel (en)Label (pt\_BR)`public`PublicPúblico`internal`InternalInterno```
use JeffersonGoncalves\KnowledgeBase\Enums\ArticleStatus;
use JeffersonGoncalves\KnowledgeBase\Enums\ArticleVisibility;

$status = ArticleStatus::Published;
$status->label(); // 'Published' or 'Publicado'

$visibility = ArticleVisibility::Internal;
$visibility->label(); // 'Internal' or 'Interno'
```

Database Tables
---------------

[](#database-tables)

All tables use the configured prefix (default: `kb_`):

TableDescription`kb_categories`Hierarchical article categories`kb_articles`Knowledge base articles`kb_article_versions`Article version history`kb_article_feedback`User feedback on articles`kb_article_relations`Related articles (pivot)Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance87

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

3

Last Release

77d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/411493?v=4)[Jefferson Gonçalves](/maintainers/jeffersongoncalves)[@jeffersongoncalves](https://github.com/jeffersongoncalves)

---

Top Contributors

[![jeffersongoncalves](https://avatars.githubusercontent.com/u/411493?v=4)](https://github.com/jeffersongoncalves "jeffersongoncalves (11 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

articlescategoriescmscomposerdocumentationfeedbackjeffersongoncalvesknowledge-baselaravellaravel-packagephpsearchversioningwikilaraveldocumentationarticleswikiKnowledge BaseFAQkb

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jeffersongoncalves-laravel-knowledge-base/health.svg)

```
[![Health](https://phpackages.com/badges/jeffersongoncalves-laravel-knowledge-base/health.svg)](https://phpackages.com/packages/jeffersongoncalves-laravel-knowledge-base)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
