📦 Liauwmedia Package Registry

Private package repository for liauwmedia ecosystem

← Back to Packages

liauwmedia/admin

Core admin package for Liauwmedia ecosystem with package discovery and management

By MIT
Downloads
0
Rating
0.0 / 5.0
Popularity
0.0
Versions
1

Installation

composer require liauwmedia/admin

README

Liauwmedia Admin Package

A comprehensive Laravel admin panel package with RBAC, modules system, package management, and multi-language support.

Features

  • 🔐 Authentication - Laravel Fortify integration with 2FA support
  • 👥 RBAC - Role-based access control using Spatie Permission
  • 📦 Package Discovery - Auto-discover installed + available packages
  • 🌐 Registry Integration - Browse packages from packages.liauw-media.com
  • 🔧 Module System - Auto-discovery and management of admin modules
  • 🌍 Translations - Database-driven translation system
  • ⚙️ Scheduler Management - Web UI for Laravel scheduled tasks
  • 🎨 Beautiful UI - Modern, responsive admin dashboard

Requirements

  • PHP 8.1+
  • Laravel 10.x or 11.x or 12.x
  • MySQL/PostgreSQL
  • Composer 2.0+

Installation

Step 1: Add Package Repository

Add the Liauwmedia Package Registry to your composer.json:

{
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.liauw-media.com"
        },
        {
            "type": "vcs",
            "url": "https://gitlab.liauw-media.de/liauwmedia/admin.git"
        }
    ]
}

For local development, use path repository instead:

{
    "repositories": [
        {
            "type": "path",
            "url": "./packages/liauwmedia-admin"
        }
    ]
}

Step 2: Install Package

# For local development (will show as dev-main)
composer require liauwmedia/admin:@dev

# Note: Path repositories always show as 'dev-main' in composer.lock
# See INSTALLATION.md for versioning options

Step 3: Install Required Dependencies

IMPORTANT: These packages MUST be installed before running admin:install:

# Install Spatie Permission (REQUIRED for RBAC)
composer require spatie/laravel-permission

# Install Laravel Fortify (Optional but recommended for authentication)
composer require laravel/fortify

If Spatie Permission is not installed, the installation will fail.

Step 4: Run Installation Command

# Interactive installation (recommended)
php artisan admin:install

# Or specify options
php artisan admin:install --route-prefix=dashboard

# Non-interactive with defaults
php artisan admin:install --non-interactive

This command will:

  • Ask for your preferred admin route prefix (with suggestions)
  • Publish configuration files with embedded route prefix
  • Publish routes file to routes/admin.php with your chosen prefix
  • Publish ALL migrations (admin + Spatie Permission)
  • Publish views and seeders
  • Configure Fortify (if installed)
  • Offer to run migrations
  • Offer to seed default data (roles, permissions, admin user)

Step 5: Complete Setup

If you didn't run migrations during installation:

# Run migrations
php artisan migrate

# Setup default data (roles, permissions, translations)
php artisan admin:setup

Step 6: Configure User Model

Ensure your User model has the admin trait:

<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Liauwmedia\Admin\Traits\HasAdminRoles;

class User extends Authenticatable
{
    use HasAdminRoles;

    // ... rest of your model
}

Step 7: Create Admin User

If you didn't create an admin user during setup:

// In tinker or a seeder
$user = User::create([
    'name' => 'Admin',
    'email' => 'admin@example.com',
    'password' => bcrypt('password'),
]);

$user->assignRole('super-admin');

Configuration

Configuration

The admin panel configuration is stored in config/admin.php. The route prefix you chose during installation is hardcoded in:

  • routes/admin.php - The actual route definitions
  • config/admin.php - For reference by other packages

No environment variables are needed for the route prefix as it's embedded directly in the files during installation.

Config Files

  • config/admin.php - Main admin configuration
  • config/fortify.php - Authentication configuration (if using Fortify)
  • config/permission.php - Spatie Permission configuration

Usage

Accessing the Admin Panel

After installation, access your admin panel at:

http://your-domain.com/wp-admin

(Or whatever route prefix you configured)

Default Roles

The package creates three default roles:

  • super-admin - Full system access
  • admin - Administrative access
  • editor - Content editing access

Available Commands

# Install the package
php artisan admin:install

# Setup default data (run after migrations)
php artisan admin:setup

# Update the package (preserves customizations)
php artisan admin:update

# Uninstall the package and clean up
php artisan admin:uninstall

# Configure Fortify integration only
php artisan admin:install --fortify-only

# Discover and register modules
php artisan admin:discover-modules

# List all installed packages
php artisan admin:packages

# List packages by category
php artisan admin:packages --category=seo

# Output as JSON
php artisan admin:packages --json

# Clear package discovery cache
php artisan admin:packages --clear-cache

Package Discovery

The admin package provides comprehensive package management with registry integration.

Via Web Dashboard

Access the packages dashboard at /{route-prefix}/packages:

Features:

  • 📋 View all installed Liauwmedia packages
  • 🌐 Browse available packages from packages.liauw-media.com
  • 🔍 Filter by category (tracking, SEO, security, etc.)
  • 📊 View statistics and dependencies
  • 🔗 View package details and repository links
  • 📦 Get installation instructions for available packages

Via PHP/Artisan

use Liauwmedia\Admin\Services\PackageDiscoveryService;

$discovery = app(PackageDiscoveryService::class);

// Get installed packages
$installed = $discovery->discoverPackages();

// Get available packages from registry
$available = $discovery->discoverAvailablePackages();

// Get all packages (installed + available) with installation status
$all = $discovery->discoverAllPackages();

// Check if package is installed
$isInstalled = $discovery->isInstalled('liauwmedia/tracking');

// Get specific package
$package = $discovery->getPackage('liauwmedia/tracking');

// Get packages by category
$seoPackages = $discovery->getPackagesByCategory('seo');

// Get statistics
$stats = $discovery->getStatistics();
// ['total_packages', 'with_service_providers', 'total_dependencies', 'categories']

// Clear cache
$discovery->clearCache();

API Endpoints

GET /{route-prefix}/packages              # List all packages
GET /{route-prefix}/packages/json         # JSON endpoint
GET /{route-prefix}/packages/{name}       # Package details
GET /{route-prefix}/packages/category/{category}  # Filter by category
GET /{route-prefix}/packages/statistics   # Package statistics
POST /{route-prefix}/packages/cache/clear # Clear cache

Configuration

Configure package discovery in config/admin.php:

'package_discovery' => [
    'vendor' => 'liauwmedia',
    'registry_url' => env('LIAUWMEDIA_REGISTRY_URL', 'https://packages.liauw-media.com'),
    'cache_enabled' => true,
    'cache_ttl' => 3600, // 1 hour
    'categories' => [
        'tracking' => ['tracking', 'analytics', 'pixel'],
        'seo' => ['seo', 'sitemap', 'meta'],
        // ... more categories
    ],
],

Module System

The admin package supports a modular architecture. Modules can be installed as separate packages.

Creating a Module

Create a service provider that implements the module interface:

namespace YourVendor\YourModule;

use Liauwmedia\Admin\Contracts\ModuleInterface;

class YourModuleServiceProvider extends ServiceProvider implements ModuleInterface
{
    public function getModuleConfig(): array
    {
        return [
            'name' => 'your-module',
            'display_name' => 'Your Module',
            'description' => 'Module description',
            'version' => '1.0.0',
            'routes' => __DIR__ . '/../routes/admin.php',
            'views' => __DIR__ . '/../resources/views',
            'migrations' => __DIR__ . '/../database/migrations',
        ];
    }
}

Emergency Repair

If you encounter errors that prevent artisan commands from running (like duplicate route includes):

# Run the emergency repair script directly
php vendor/liauwmedia/admin/emergency-repair.php

# Then clear caches
php artisan config:clear
php artisan route:clear

This script can fix:

  • Duplicate admin route includes in routes/web.php
  • Missing routes/admin.php file
  • Unregistered FortifyServiceProvider

Troubleshooting

Migration Cleanup

If you're upgrading from an older version or experiencing migration issues, the install command will automatically clean up old migrations. You can also manually remove them:

# Remove old admin_translations migrations
rm database/migrations/*admin_translations*.php

# If the table exists, drop it
php artisan tinker
>>> Schema::dropIfExists('admin_translations');

"Base table or view not found: admin_translations"

This error occurs if you have an old version. The package no longer uses admin_translations table. Solution:

php artisan migrate
php artisan admin:setup

Permission denied errors

Ensure proper file permissions:

chmod -R 775 storage bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache

Fortify not configured

If you see authentication errors:

php artisan vendor:publish --provider="Laravel\Fortify\FortifyServiceProvider"

Then configure config/fortify.php and add FortifyServiceProvider to config/app.php.

Package Management

Updating the Package

The package includes smart update handling:

# Update all package files (will prompt before overwriting customizations)
php artisan admin:update

# Force update all files
php artisan admin:update --force

# Update only configuration files
php artisan admin:update --config-only

# Update only migrations
php artisan admin:update --migrations-only

The update command:

  • Checks for file changes before overwriting
  • Preserves your customizations by default
  • Tracks package version and installation manifest
  • Only updates files that have actually changed

Removing the Package

To cleanly remove the package:

# Remove package files and data (with confirmations)
php artisan admin:uninstall

# Force removal without prompts
php artisan admin:uninstall --force

# Keep database data
php artisan admin:uninstall --keep-data

# Keep configuration files
php artisan admin:uninstall --keep-config

# Then remove from composer
composer remove liauwmedia/admin

The uninstall command:

  • Removes all published files and directories
  • Optionally drops database tables
  • Cleans up config/app.php and routes/web.php
  • Removes installation manifest

Installation Tracking

The package creates a .admin-manifest.json file to track:

  • Installed version
  • Published files
  • Configured features (Fortify, etc.)
  • Installation date and settings

This allows for smart updates and clean removals.

License

MIT License

Versions

1.0.0 Oct 13, 2025

Links