Professional Laravel CMS with Filament 4 admin panel - standalone deployable

Installs: 6

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

pkg:composer/netserva/cms

v0.0.11 2025-11-06 11:34 UTC

This package is auto-updated.

Last update: 2025-11-06 11:44:24 UTC


README

Professional Laravel 12 + Filament 4 Content Management System

Laravel Filament PHP Pest

๐ŸŽฏ Design Philosophy: Standalone & Deployable Built to work both within NetServa 3.0 AND as a completely standalone Laravel package

โœจ Features

Content Management

  • ๐Ÿ“„ Hierarchical Pages - Nested page structure with multiple templates
  • ๐Ÿ“ Blog System - Full-featured blogging with categories and tags
  • ๐Ÿท๏ธ Categories & Tags - Organize content with taxonomies
  • ๐Ÿ” Menu Builder - Flexible JSON-based navigation with nested items
  • ๐ŸŽจ Multiple Templates - Homepage, Service, Pricing, Default, and Blank layouts

Media & SEO

  • ๐Ÿ–ผ๏ธ Media Library - Spatie Media Library with featured images & galleries
  • ๐Ÿ” SEO Optimized - Meta tags, Open Graph, Twitter Cards built-in
  • ๐Ÿ“Š Reading Time - Automatic word count and reading time calculation
  • ๐Ÿ”— Sluggable URLs - Automatic SEO-friendly URL generation

Admin Experience

  • ๐ŸŽ›๏ธ Filament 4 Admin - Modern, beautiful admin interface
  • โœ๏ธ Rich Editor - Full-featured content editing with file attachments
  • ๐ŸŒ“ Dark Mode - Full dark mode support throughout
  • ๐Ÿ“ฑ Responsive - Mobile-first admin panel design

Developer Experience

  • โœ… Zero Dependencies - NO NetServa dependencies, works anywhere
  • ๐Ÿงช Comprehensive Tests - 70+ Pest tests with 100% coverage goal
  • ๐Ÿญ Model Factories - Full factory support for testing
  • ๐ŸŽฏ Type Safe - PHP 8.4 with full type declarations
  • ๐Ÿ”’ Soft Deletes - Safe content management

๐Ÿ“‹ Requirements

  • PHP: ^8.4
  • Laravel: ^12.0
  • Filament: ^4.0
  • Spatie Media Library: ^11.0
  • Spatie Sluggable: ^3.0

๐Ÿš€ Quick Start

Installation

composer require netserva/cms

Publish Configuration

php artisan vendor:publish --provider="NetServa\Cms\NetServaCmsServiceProvider"

Run Migrations

php artisan migrate

Register Filament Plugin

In your Filament panel provider (app/Providers/Filament/AdminPanelProvider.php):

use NetServa\Cms\NetServaCmsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            NetServaCmsPlugin::make(),
        ]);
}

Access Admin Panel

Visit /admin and start creating content!

๐Ÿ“Š Database Schema

All tables use the cms_ prefix to prevent conflicts:

Table Purpose
cms_pages Hierarchical page structure with templates
cms_posts Blog posts with word count tracking
cms_categories Multi-type categories (post, portfolio, news, docs)
cms_tags Post tagging system
cms_post_tag Many-to-many pivot table
cms_menus JSON-based navigation menus
media Spatie Media Library tables

๐Ÿ—๏ธ Architecture

Models (100% Standalone)

All models are completely standalone with ZERO dependencies on NetServa Core:

NetServa\Cms\Models\
โ”œโ”€โ”€ Page       // Hierarchical pages with templates & SEO
โ”œโ”€โ”€ Post       // Blog posts with categories, tags & media
โ”œโ”€โ”€ Category   // Multi-type categories with type scoping
โ”œโ”€โ”€ Tag        // Simple tag model with post relationships
โ””โ”€โ”€ Menu       // JSON-based menu with hierarchical items

Controllers

NetServa\Cms\Http\Controllers\
โ”œโ”€โ”€ PageController  // home(), show(), showNested()
โ””โ”€โ”€ PostController  // index(), show(), category(), tag()

Filament Resources

NetServa\Cms\Filament\Resources\
โ”œโ”€โ”€ PageResource      // Full CRUD for pages
โ”œโ”€โ”€ PostResource      // Full CRUD for posts
โ”œโ”€โ”€ CategoryResource  // Manage categories
โ”œโ”€โ”€ TagResource       // Manage tags
โ””โ”€โ”€ MenuResource      // Menu builder with nested repeaters

Views

resources/views/
โ”œโ”€โ”€ layouts/
โ”‚   โ””โ”€โ”€ app.blade.php                    // Main layout with SEO & menus
โ”œโ”€โ”€ pages/templates/
โ”‚   โ”œโ”€โ”€ default.blade.php                // Standard page
โ”‚   โ”œโ”€โ”€ homepage.blade.php               // Hero, features, CTA
โ”‚   โ”œโ”€โ”€ service.blade.php                // Service page with sidebar
โ”‚   โ”œโ”€โ”€ pricing.blade.php                // 3-tier pricing cards
โ”‚   โ””โ”€โ”€ blank.blade.php                  // Minimal template
โ””โ”€โ”€ posts/
    โ”œโ”€โ”€ index.blade.php                  // Blog archive with search
    โ”œโ”€โ”€ show.blade.php                   // Single post with related
    โ”œโ”€โ”€ category.blade.php               // Category archive
    โ””โ”€โ”€ tag.blade.php                    // Tag archive

๐ŸŽจ Usage Examples

Creating Pages

use NetServa\Cms\Models\Page;

$homepage = Page::factory()->homepage()->create([
    'title' => 'Welcome to My Site',
    'content' => '<p>Homepage content...</p>',
]);

$about = Page::factory()->create([
    'title' => 'About Us',
    'template' => 'default',
    'parent_id' => null,
]);

Creating Blog Posts

use NetServa\Cms\Models\Post;
use NetServa\Cms\Models\Category;
use NetServa\Cms\Models\Tag;

$category = Category::factory()->post()->create(['name' => 'Tutorials']);
$tags = Tag::factory()->count(3)->create();

$post = Post::factory()->create([
    'title' => 'Getting Started with Laravel',
    'content' => '<p>Post content...</p>',
]);

$post->categories()->attach($category);
$post->tags()->attach($tags);

Building Menus

use NetServa\Cms\Models\Menu;

$menu = Menu::factory()->header()->create([
    'name' => 'Main Navigation',
    'items' => [
        [
            'label' => 'Home',
            'url' => '/',
            'order' => 0,
            'children' => [],
        ],
        [
            'label' => 'Services',
            'url' => '/services',
            'order' => 1,
            'children' => [
                ['label' => 'Web Development', 'url' => '/services/web'],
                ['label' => 'Hosting', 'url' => '/services/hosting'],
            ],
        ],
    ],
]);

๐Ÿงช Testing

Running Tests

# Run all tests
php artisan test

# Run specific test file
php artisan test packages/netserva-cms/tests/Unit/Models/PageTest.php

# Run with coverage
php artisan test --coverage

Test Coverage

  • Model Tests: 40 tests covering all models
  • Controller Tests: 25 tests for PageController & PostController
  • Resource Tests: 30+ tests for Filament resources
  • Total: 95+ comprehensive tests

Using Factories

use NetServa\Cms\Models\Page;

// Create a single page
$page = Page::factory()->create();

// Create 10 published pages
$pages = Page::factory()->count(10)->published()->create();

// Create a homepage
$homepage = Page::factory()->homepage()->create();

// Create nested pages
$parent = Page::factory()->create();
$child = Page::factory()->create(['parent_id' => $parent->id]);

โš™๏ธ Configuration

Published to config/netserva-cms.php:

return [
    'frontend' => [
        'enabled' => true,
    ],

    'blog' => [
        'route_prefix' => 'blog',
        'posts_per_page' => 12,
    ],

    'seo' => [
        'site_name' => env('APP_NAME', 'NetServa CMS'),
        'site_description' => 'Professional CMS built on Laravel',
    ],

    'media' => [
        'disk' => 'public',
        'max_file_size' => 10240, // KB
    ],

    'templates' => [
        'default' => 'Default Page',
        'homepage' => 'Homepage',
        'service' => 'Service Page',
        'pricing' => 'Pricing Page',
        'blank' => 'Blank Page',
    ],
];

๐ŸŽฏ Routes

Frontend Routes

// Homepage
GET  /                           // PageController@home

// Pages
GET  /{slug}                     // PageController@show
GET  /{parentSlug}/{slug}        // PageController@showNested

// Blog
GET  /blog                       // PostController@index
GET  /blog/{slug}                // PostController@show
GET  /blog/category/{slug}       // PostController@category
GET  /blog/tag/{slug}            // PostController@tag

Admin Routes

All admin routes are handled by Filament at /admin:

  • /admin/pages - Page management
  • /admin/posts - Post management
  • /admin/categories - Category management
  • /admin/tags - Tag management
  • /admin/menus - Menu builder

๐Ÿš€ Deployment Scenarios

Dual-Purpose Architecture

The netserva-cms package is designed to work in two distinct deployment modes:

1. Integrated Mode (Within NetServa 3.0)

When installed as part of the NetServa 3.0 platform:

Purpose: Provides professional frontend pages for NetServa installations

Routes:

/                    โ†’ CMS homepage (NetServa.org branding)
/blog                โ†’ Blog posts about NetServa updates
/about               โ†’ About NetServa platform
/features            โ†’ NetServa features page
/admin               โ†’ Filament admin (all NetServa plugins)
/admin/pages         โ†’ CMS page management
/admin/vnodes        โ†’ Server management (other plugins)

Default Content:

  • Homepage: NetServa platform introduction
  • About page: Platform explanation
  • Features page: Capability overview
  • Sample blog post: "Welcome to NetServa 3.0"

Benefits:

  • โœ… Professional landing page for NetServa installations
  • โœ… Explains platform capabilities to visitors
  • โœ… Integrated with other NetServa admin panels
  • โœ… Gets constant updates via NS 3.0 development

2. Standalone Mode (Independent Laravel Project)

When installed in a fresh Laravel 12 project:

Purpose: Power standalone websites (client sites, marketing sites, etc.)

Routes:

/                    โ†’ Client homepage
/blog                โ†’ Client blog
/{slug}              โ†’ Client pages
/admin               โ†’ CMS admin panel only

Client Content Examples:

  • SpiderWeb website (spiderweb.com.au) โ†’ separate GitHub repo
  • Other client marketing sites
  • Personal blogs or portfolios

Installation:

# Fresh Laravel 12 project
composer create-project laravel/laravel my-client-site
cd my-client-site

# Install CMS
composer require netserva/cms

# Configure & migrate
php artisan vendor:publish --provider="NetServa\Cms\NetServaCmsServiceProvider"
php artisan migrate

# Seed with default content OR import client content
php artisan db:seed --class="NetServa\Cms\Database\Seeders\NetServaCmsSeeder"

Benefits:

  • โœ… Zero NetServa dependencies
  • โœ… Standalone CMS capabilities
  • โœ… Benefits from NS 3.0 CMS development
  • โœ… Can be customized per client

Content Separation Strategy

Default Content (Included in Repository):

  • Professional NetServa.org branding
  • General server management messaging
  • Suitable for any NetServa installation

Client Content (NOT in Repository):

  • SpiderWeb website content โ†’ spiderweb-website repo
  • Other client sites โ†’ separate repos/projects
  • Imported via seeders or manual entry

Why This Separation Matters:

  1. Repository Cleanliness - No client-specific data in main repo
  2. Privacy - Client content stays private to client
  3. Reusability - Same CMS package powers unlimited sites
  4. Updates - CMS improvements benefit all deployments

Migration Example: SpiderWeb

Current State: WordPress website at spiderweb.com.au

Future Workflow:

# 1. Create separate project
git clone <spiderweb-website-repo>
cd spiderweb-website

# 2. Fresh Laravel + CMS
composer create-project laravel/laravel .
composer require netserva/cms

# 3. Import WordPress content
php artisan cms:import:wordpress /path/to/wordpress-export.xml

# 4. Deploy separately
# (SpiderWeb runs independently of NetServa 3.0)

Result:

  • SpiderWeb gets modern Laravel/Filament CMS
  • Benefits from NetServa CMS improvements
  • Completely separate GitHub repo
  • No NetServa platform dependency

Routing Behavior

With CMS Installed:

  • CMS owns root / route
  • Provides homepage, pages, blog routes
  • Fallback to Laravel welcome disabled

Without CMS:

  • Root / shows Laravel welcome page
  • Only /admin panel available
  • Clean backend-only installation

Environment Configuration:

# Enable/disable CMS frontend
CMS_FRONTEND_ENABLED=true

# Customize route prefixes
CMS_BLOG_PREFIX=blog
CMS_PORTFOLIO_PREFIX=portfolio

# Admin panel path (security)
NS_ADMIN_PREFIX=admin

๐Ÿ”’ Design Constraints

โœ… ALWAYS DO

// โœ… Implement Plugin directly
class NetServaCmsPlugin implements Plugin { }

// โœ… Use own models only
namespace NetServa\Cms\Models;

// โœ… Keep composer.json clean
"require": {
    "laravel/framework": "^12.0",
    "filament/filament": "^4.0"
}

โŒ NEVER DO

// โŒ Don't extend BaseFilamentPlugin
class NetServaCmsPlugin extends BaseFilamentPlugin { }

// โŒ Don't use NetServa Core models
use NetServa\Core\Models\VHost;

// โŒ Don't add NetServa dependencies
"require": { "netserva/core": "*" }

๐Ÿ” Verification

Verify zero NetServa dependencies:

# Should return nothing
grep -r "NetServa\\Core" packages/netserva-cms/src/

# Should return nothing
grep -r "use NetServa" packages/netserva-cms/src/ | grep -v "NetServa\\Cms"

# Should show only Laravel/Filament/Spatie packages
cat packages/netserva-cms/composer.json | jq '.require'

๐Ÿ“‚ Complete Directory Structure

packages/netserva-cms/
โ”œโ”€โ”€ composer.json                         # Zero NS dependencies โœ…
โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ netserva-cms.php                 # Published configuration
โ”œโ”€โ”€ database/
โ”‚   โ”œโ”€โ”€ factories/                       # Model factories
โ”‚   โ”‚   โ”œโ”€โ”€ PageFactory.php
โ”‚   โ”‚   โ”œโ”€โ”€ PostFactory.php
โ”‚   โ”‚   โ”œโ”€โ”€ CategoryFactory.php
โ”‚   โ”‚   โ”œโ”€โ”€ TagFactory.php
โ”‚   โ”‚   โ””โ”€โ”€ MenuFactory.php
โ”‚   โ””โ”€โ”€ migrations/                      # cms_* prefixed tables
โ”‚       โ”œโ”€โ”€ 2024_01_01_000001_create_cms_pages_table.php
โ”‚       โ”œโ”€โ”€ 2024_01_01_000002_create_cms_categories_table.php
โ”‚       โ”œโ”€โ”€ 2024_01_01_000003_create_cms_tags_table.php
โ”‚       โ”œโ”€โ”€ 2024_01_01_000004_create_cms_posts_table.php
โ”‚       โ”œโ”€โ”€ 2024_01_01_000005_create_cms_post_tag_table.php
โ”‚       โ”œโ”€โ”€ 2024_01_01_000006_create_cms_menus_table.php
โ”‚       โ””โ”€โ”€ 2024_01_01_000007_create_media_table.php
โ”œโ”€โ”€ resources/views/
โ”‚   โ”œโ”€โ”€ layouts/
โ”‚   โ”‚   โ””โ”€โ”€ app.blade.php
โ”‚   โ”œโ”€โ”€ pages/templates/
โ”‚   โ”‚   โ”œโ”€โ”€ default.blade.php
โ”‚   โ”‚   โ”œโ”€โ”€ homepage.blade.php
โ”‚   โ”‚   โ”œโ”€โ”€ service.blade.php
โ”‚   โ”‚   โ”œโ”€โ”€ pricing.blade.php
โ”‚   โ”‚   โ””โ”€โ”€ blank.blade.php
โ”‚   โ””โ”€โ”€ posts/
โ”‚       โ”œโ”€โ”€ index.blade.php
โ”‚       โ”œโ”€โ”€ show.blade.php
โ”‚       โ”œโ”€โ”€ category.blade.php
โ”‚       โ””โ”€โ”€ tag.blade.php
โ”œโ”€โ”€ routes/
โ”‚   โ””โ”€โ”€ web.php
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ Filament/Resources/
โ”‚   โ”‚   โ”œโ”€โ”€ PageResource.php             # 3 pages (List, Create, Edit)
โ”‚   โ”‚   โ”œโ”€โ”€ PostResource.php             # 3 pages
โ”‚   โ”‚   โ”œโ”€โ”€ CategoryResource.php         # 3 pages
โ”‚   โ”‚   โ”œโ”€โ”€ TagResource.php              # 3 pages
โ”‚   โ”‚   โ””โ”€โ”€ MenuResource.php             # 3 pages
โ”‚   โ”œโ”€โ”€ Http/Controllers/
โ”‚   โ”‚   โ”œโ”€โ”€ PageController.php
โ”‚   โ”‚   โ””โ”€โ”€ PostController.php
โ”‚   โ”œโ”€โ”€ Models/
โ”‚   โ”‚   โ”œโ”€โ”€ Page.php                     # NO NS relationships โœ…
โ”‚   โ”‚   โ”œโ”€โ”€ Post.php                     # 100% standalone โœ…
โ”‚   โ”‚   โ”œโ”€โ”€ Category.php
โ”‚   โ”‚   โ”œโ”€โ”€ Tag.php
โ”‚   โ”‚   โ””โ”€โ”€ Menu.php
โ”‚   โ”œโ”€โ”€ NetServaCmsPlugin.php            # Implements Plugin โœ…
โ”‚   โ””โ”€โ”€ NetServaCmsServiceProvider.php
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ Feature/
โ”‚   โ”‚   โ”œโ”€โ”€ Controllers/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ PageControllerTest.php
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ PostControllerTest.php
โ”‚   โ”‚   โ””โ”€โ”€ Filament/
โ”‚   โ”‚       โ”œโ”€โ”€ PageResourceTest.php
โ”‚   โ”‚       โ”œโ”€โ”€ PostResourceTest.php
โ”‚   โ”‚       โ””โ”€โ”€ MenuResourceTest.php
โ”‚   โ””โ”€โ”€ Unit/Models/
โ”‚       โ”œโ”€โ”€ PageTest.php
โ”‚       โ”œโ”€โ”€ PostTest.php
โ”‚       โ”œโ”€โ”€ CategoryTest.php
โ”‚       โ”œโ”€โ”€ TagTest.php
โ”‚       โ””โ”€โ”€ MenuTest.php
โ”œโ”€โ”€ DEVELOPMENT_STATUS.md
โ””โ”€โ”€ README.md

๐Ÿ“ˆ Progress

  • โœ… Package foundation (composer.json, service provider, plugin)
  • โœ… Database migrations (7 tables with cms_ prefix)
  • โœ… Models (5 models, 100% standalone)
  • โœ… Filament resources (5 resources, 17 pages)
  • โœ… Frontend controllers (PageController, PostController)
  • โœ… Blade templates (1 layout, 9 templates)
  • โœ… Model factories (5 factories)
  • โœ… Comprehensive tests (95+ tests)
  • โœ… Documentation (README, DEVELOPMENT_STATUS)
  • โณ Run migrations (pending artisan fix)
  • โณ SpiderWeb content migration

Status: ~85% Complete

๐Ÿ“ License

MIT

๐Ÿ‘ฅ Authors

NetServa Team

๐Ÿค Contributing

This is a NetServa internal package. For issues or feature requests, please contact the NetServa development team.

Built with โค๏ธ using Laravel 12 + Filament 4