Installation Add the bundle to your Laravel project via Composer:
composer require masando/edemy-wikibundle
Register the bundle in config/app.php under providers:
Masando\WikiBundle\WikiServiceProvider::class,
Publish the migration and config files:
php artisan vendor:publish --provider="Masando\WikiBundle\WikiServiceProvider"
Run the migrations:
php artisan migrate
First Use Case Create a wiki page via Tinker or a controller:
use Masando\WikiBundle\Models\WikiPage;
$page = WikiPage::create([
'title' => 'Getting Started',
'content' => '# Welcome to the Wiki!',
'slug' => 'getting-started',
]);
Access the page via a route (ensure WikiController is registered):
Route::get('/wiki/{slug}', [\Masando\WikiBundle\Http\Controllers\WikiController::class, 'show']);
Page Management
WikiPage model or the provided form requests (StoreWikiPageRequest, UpdateWikiPageRequest).
$page = WikiPage::updateOrCreate(
['slug' => 'new-page'],
['title' => 'Updated Title', 'content' => '# New Content']
);
versions() relationship to track changes:
$page->versions()->latest()->first();
Routing & Controllers
WikiController or create custom routes:
Route::prefix('wiki')->group(function () {
Route::get('/search', [\App\Http\Controllers\WikiController::class, 'search']);
});
WikiService for business logic:
$this->wikiService->renderPage($slug); // Hypothetical method
Markdown Support
commonmark/commonmark:
use CommonMark\CommonMarkConverter;
$converter = new CommonMarkConverter();
$html = $converter->convert($page->content);
Access Control
// app/Policies/WikiPagePolicy.php
public function view(User $user, WikiPage $page) {
return $user->isAdmin || $page->isPublic();
}
Missing Dependencies
masando/edemy-framework is installed. If not, expect undefined class/method errors. Verify compatibility with your Laravel version (likely 8.x+).Slug Conflicts
generateSlug() method in WikiPage if needed:
protected static function generateSlug($title) {
return Str::slug($title . '-' . uniqid());
}
Versioning Overhead
No Built-in Search
use Masando\WikiBundle\Scout\WikiPageScout;
// In WikiPage model
public function shouldSearchable() { return true; }
php artisan route:list to verify wiki routes are registered.\Log::debug('Wiki content:', ['content' => $page->content]);
wiki_pages and wiki_page_versions tables for unexpected data.Custom Fields
Extend the WikiPage model to add metadata:
// app/Models/WikiPage.php
protected $casts = [
'is_featured' => 'boolean',
'publish_date' => 'datetime',
];
Event Listeners
Hook into wiki events (e.g., WikiPageCreated) in EventServiceProvider:
protected $listen = [
\Masando\WikiBundle\Events\WikiPageCreated::class => [
\App\Listeners\NotifyWikiEdit::class,
],
];
API Endpoints Use Laravel API Resources to expose wiki data:
// app/Http/Resources/WikiPageResource.php
public function toArray($request) {
return [
'title' => $this->title,
'url' => route('wiki.show', $this->slug),
];
}
How can I help you explore Laravel packages today?