Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cms Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. 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
    
  2. First Use Case: Basic Page Management

    • Create a page model extending Burgov\CMSBundle\Models\Page:
      php artisan make:model Page -m --model=Burgov\CMSBundle\Models\Page
      
    • Define a migration for custom fields (e.g., title, content):
      Schema::create('pages', function (Blueprint $table) {
          $table->id();
          $table->string('title');
          $table->text('content');
          $table->timestamps();
      });
      
    • Register the model in config/cms.php:
      'models' => [
          'page' => \App\Models\Page::class,
      ],
      
  3. Admin Panel Access the admin panel at /admin (default route). The bundle provides a basic CRUD interface for managing pages.


Implementation Patterns

Workflows

  1. Content Management

    • Use the 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]);
      
    • Dynamic content rendering:
      $content = CMS::render($page->content); // Parse and render content (e.g., markdown, HTML)
      
  2. Routing

    • Define CMS routes in routes/web.php:
      Route::get('/about', [\Burgov\CMSBundle\Http\Controllers\PageController::class, 'show'])->name('cms.page');
      
    • Use the CMS facade to resolve pages by slug:
      $page = CMS::page()->where('slug', 'about')->firstOrFail();
      
  3. Extensions

    • Add custom fields to the Page model:
      class Page extends \Burgov\CMSBundle\Models\Page
      {
          protected $casts = [
              'is_published' => 'boolean',
              'meta_description' => 'string',
          ];
      }
      
    • Extend the admin panel by overriding views in resources/views/vendor/cms-bundle/.
  4. Localization

    • Support multilingual content by adding a locale column to the pages table and using Laravel’s localization features:
      $page = CMS::page()->where('slug', 'about')->where('locale', app()->getLocale())->first();
      

Integration Tips

  • Laravel Scout: Index pages for search functionality:
    use Laravel\Scout\Searchable;
    
    class Page extends \Burgov\CMSBundle\Models\Page
    {
        use Searchable;
    }
    
  • Media Library: Integrate with spatie/laravel-medialibrary for page attachments:
    $page->addMedia(storage_path('app/public/image.jpg'))->toMediaCollection('page-images');
    
  • Events: Listen for page updates:
    \Burgov\CMSBundle\Models\Page::updated(function ($page) {
        // Send notification or log changes
    });
    

Gotchas and Tips

Pitfalls

  1. Model Naming Conflicts

    • Ensure your Page model does not conflict with Laravel’s built-in Page class (if any). Use a namespace like App\Models\CMS\Page.
  2. Missing Config

    • Forgetting to publish the config (php artisan vendor:publish --tag=config) will result in undefined routes or facades.
  3. Admin Panel Permissions

    • The bundle does not include authentication. Use Laravel’s built-in auth or a package like spatie/laravel-permission to restrict access to /admin.
  4. Content Parsing Issues

    • The CMS::render() method may not handle all markdown or HTML edge cases. Test with complex content (e.g., nested lists, custom HTML tags).
  5. Route Caching

    • Clear route cache after adding new CMS routes:
      php artisan route:clear
      

Debugging

  • Check Logs: Enable debug mode (APP_DEBUG=true in .env) to inspect admin panel errors.
  • SQL Queries: Use Laravel Debugbar to inspect queries related to the pages table.
  • View Overrides: If custom admin views aren’t loading, verify the override path (resources/views/vendor/cms-bundle/).

Extension Points

  1. Custom Fields

    • Extend the Page model to add custom attributes or relationships:
      public function categories()
      {
          return $this->belongsToMany(Category::class);
      }
      
  2. Content Editors

    • Replace the default WYSIWYG editor by overriding the admin panel’s JavaScript/CSS:
      // resources/js/admin.js
      document.addEventListener('DOMContentLoaded', function() {
          // Custom editor logic
      });
      
  3. API Endpoints

    • Create API routes for pages:
      Route::apiResource('pages', \Burgov\CMSBundle\Http\Controllers\API\PageController::class);
      
  4. Middleware

    • Add middleware to CMS routes for logging or analytics:
      Route::get('/about', [PageController::class, 'show'])->middleware('log.view')->name('cms.page');
      
  5. Testing

    • Use Laravel’s testing tools to assert CMS functionality:
      $response = $this->get('/admin/pages');
      $response->assertStatus(200);
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
graham-campbell/flysystem
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
directorytree/opensearch-client
directorytree/opensearch-adapter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin