burgov/cms-bundle
Burgov CMS Bundle is a Laravel/PHP package that provides a CMS bundle for managing site content and related features. Designed to integrate into your application as a cohesive module for building CMS-driven sites.
Installation
composer require burgov/cms-bundle
Add to config/app.php under providers:
Burgov\CMSBundle\CMSBundle::class,
Publish the bundle’s assets and config:
php artisan vendor:publish --provider="Burgov\CMSBundle\CMSBundle" --tag=config
php artisan vendor:publish --provider="Burgov\CMSBundle\CMSBundle" --tag=public
First Use Case: Basic Page Management
Burgov\CMSBundle\Models\Page:
php artisan make:model Page -m --model=Burgov\CMSBundle\Models\Page
title, content):
Schema::create('pages', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('content');
$table->timestamps();
});
config/cms.php:
'models' => [
'page' => \App\Models\Page::class,
],
Admin Panel
Access the admin panel at /admin (default route). The bundle provides a basic CRUD interface for managing pages.
Content Management
Page model to fetch and display content:
use Burgov\CMSBundle\Facades\CMS;
$page = CMS::page()->find(1); // Fetch a page by ID
return view('page.show', ['page' => $page]);
$content = CMS::render($page->content); // Parse and render content (e.g., markdown, HTML)
Routing
routes/web.php:
Route::get('/about', [\Burgov\CMSBundle\Http\Controllers\PageController::class, 'show'])->name('cms.page');
CMS facade to resolve pages by slug:
$page = CMS::page()->where('slug', 'about')->firstOrFail();
Extensions
Page model:
class Page extends \Burgov\CMSBundle\Models\Page
{
protected $casts = [
'is_published' => 'boolean',
'meta_description' => 'string',
];
}
resources/views/vendor/cms-bundle/.Localization
locale column to the pages table and using Laravel’s localization features:
$page = CMS::page()->where('slug', 'about')->where('locale', app()->getLocale())->first();
use Laravel\Scout\Searchable;
class Page extends \Burgov\CMSBundle\Models\Page
{
use Searchable;
}
spatie/laravel-medialibrary for page attachments:
$page->addMedia(storage_path('app/public/image.jpg'))->toMediaCollection('page-images');
\Burgov\CMSBundle\Models\Page::updated(function ($page) {
// Send notification or log changes
});
Model Naming Conflicts
Page model does not conflict with Laravel’s built-in Page class (if any). Use a namespace like App\Models\CMS\Page.Missing Config
php artisan vendor:publish --tag=config) will result in undefined routes or facades.Admin Panel Permissions
spatie/laravel-permission to restrict access to /admin.Content Parsing Issues
CMS::render() method may not handle all markdown or HTML edge cases. Test with complex content (e.g., nested lists, custom HTML tags).Route Caching
php artisan route:clear
APP_DEBUG=true in .env) to inspect admin panel errors.pages table.resources/views/vendor/cms-bundle/).Custom Fields
Page model to add custom attributes or relationships:
public function categories()
{
return $this->belongsToMany(Category::class);
}
Content Editors
// resources/js/admin.js
document.addEventListener('DOMContentLoaded', function() {
// Custom editor logic
});
API Endpoints
Route::apiResource('pages', \Burgov\CMSBundle\Http\Controllers\API\PageController::class);
Middleware
Route::get('/about', [PageController::class, 'show'])->middleware('log.view')->name('cms.page');
Testing
$response = $this->get('/admin/pages');
$response->assertStatus(200);
How can I help you explore Laravel packages today?