PHPackages                             libxa/lib-admin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. libxa/lib-admin

ActiveLibxa-module[Admin Panels](/categories/admin)

libxa/lib-admin
===============

LibAdmin — Zero-config, attribute-driven admin panel for LibxaFrame

v0.0.5(2mo ago)04MITPHPPHP ^8.3

Since Apr 10Pushed 1mo agoCompare

[ Source](https://github.com/libxa-framework/lib-admin)[ Packagist](https://packagist.org/packages/libxa/lib-admin)[ RSS](/packages/libxa-lib-admin/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

LibAdmin - Admin Panel Package for LibxaFrame
=============================================

[](#libadmin---admin-panel-package-for-libxaframe)

A powerful, modular admin panel package for LibxaFrame framework that provides authentication, resource management, and a beautiful admin interface out of the box.

Features
--------

[](#features)

- 🔐 **Authentication System** - Session-based authentication with login/logout
- 👥 **User Management** - Create, read, update, and delete admin users
- 📊 **Resource Management** - Dynamic CRUD operations for any database table
- 🎨 **Beautiful UI** - Modern, responsive admin interface with shared layout
- 🔧 **Console Commands** - CLI tools for managing admin users and resources
- 📦 **Modular Architecture** - Fully integrated with LibxaFrame package system
- 🛡️ **Middleware Protection** - Route protection for authenticated and guest users
- 🔒 **Password Hashing** - Automatic bcrypt hashing for user passwords

Installation
------------

[](#installation)

LibAdmin is already integrated into your LibxaFrame application. No additional installation required.

Quick Start
-----------

[](#quick-start)

### 1. Run Migrations

[](#1-run-migrations)

```
php libxa migrate
```

This creates:

- `admin_users` - Admin user accounts
- `roles` - User roles
- `permissions` - Permission definitions
- `role_user` - Role assignments
- `permission_role` - Permission assignments
- `audit_logs` - Activity tracking
- `media` - File management

### 2. Create an Admin User

[](#2-create-an-admin-user)

```
php libxa admin:make-user
```

Follow the prompts to enter:

- Name
- Email
- Password
- Role (default: superadmin)

Or use command-line arguments:

```
php libxa admin:make-user "John Doe" "john@example.com" "password123" --role=admin
```

### 3. Access the Admin Panel

[](#3-access-the-admin-panel)

Navigate to `/admin/login` in your browser and login with the credentials you created.

Authentication
--------------

[](#authentication)

### Components

[](#components)

- **AdminUser Model** (`Libxa\Admin\Models\AdminUser`) - User model with password hashing
- **AdminGuard** (`Libxa\Admin\Auth\AdminGuard`) - Session-based authentication guard
- **AdminUserProvider** (`Libxa\Admin\Auth\AdminUserProvider`) - User retrieval and validation
- **AdminAuthMiddleware** - Protects routes requiring authentication
- **RedirectIfAuthenticated** - Redirects authenticated users from login page

### Routes

[](#routes)

```
GET  /admin/login    - Login form (guest only)
POST /admin/login    - Login submit
POST /admin/logout   - Logout (auth required)

```

Console Commands
----------------

[](#console-commands)

### admin:make-user

[](#adminmake-user)

Create a new admin user.

```
php libxa admin:make-user
php libxa admin:make-user "Name" "email@example.com" "password" --role=admin
```

### admin:make-resource

[](#adminmake-resource)

Generate a resource class for managing database tables.

```
php libxa admin:make-resource User
php libxa admin:make-resource Product --fields=name,price,description
```

### admin:roles

[](#adminroles)

List all available roles.

```
php libxa admin:roles
```

Resource Management
-------------------

[](#resource-management)

### Accessing Resources

[](#accessing-resources)

All resources follow the pattern: `/admin/resources/{resource}`

Examples:

- `/admin/resources/users` - Manage users
- `/admin/resources/products` - Manage products
- `/admin/resources/posts` - Manage blog posts

### CRUD Operations

[](#crud-operations)

#### List All Items

[](#list-all-items)

```
GET /admin/resources/{resource}

```

Displays a table with all items from the specified table.

#### Create New Item

[](#create-new-item)

```
GET /admin/resources/{resource}/create
POST /admin/resources/{resource}

```

Shows a form to create a new item. Features:

- Automatic column filtering (only inserts columns that exist)
- Automatic password hashing
- Validation

#### View Item Details

[](#view-item-details)

```
GET /admin/resources/{resource}/{id}

```

Displays all properties of a specific item with action buttons.

#### Edit Item

[](#edit-item)

```
GET /admin/resources/{resource}/{id}/edit
PUT /admin/resources/{resource}/{id}

```

Pre-filled form to edit an item. Password field can be left blank to keep current value.

#### Delete Item

[](#delete-item)

```
DELETE /admin/resources/{resource}/{id}

```

Deletes an item with confirmation prompt.

### Dynamic Table Handling

[](#dynamic-table-handling)

The ResourceController automatically adapts to any table structure:

```
public function store(Request $request, string $resource): Response
{
    $data = $request->except(['_token', '_method']);

    // Get table columns to filter data
    $columns = DB::select("PRAGMA table_info($resource)");
    $validColumns = array_column($columns, 'name');

    // Only include columns that exist in the table
    $filteredData = array_intersect_key($data, array_flip($validColumns));

    // Hash password if present
    if (isset($filteredData['password'])) {
        $filteredData['password'] = password_hash($filteredData['password'], PASSWORD_BCRYPT);
    }

    DB::table($resource)->insert($filteredData);
    return redirect("/admin/resources/$resource");
}
```

This means you can manage ANY database table without configuration!

Views and Layouts
-----------------

[](#views-and-layouts)

### Shared Layout

[](#shared-layout)

All admin pages use `resources/views/layouts/admin.blade.php`:

- **Sidebar** - Navigation menu with links to Dashboard and resources
- **Header** - Page title, user welcome message, logout button
- **Content Area** - Page-specific content

### Available Views

[](#available-views)

1. **Dashboard** (`admin::dashboard`)

    - Welcome screen with navigation
2. **Login** (`admin::auth.login`)

    - Login form with remember me option
    - Error message display
3. **Resource Index** (`admin::resources.index`)

    - Table view of all items
    - Dynamic column headers based on table structure
    - Action buttons (View, Edit, Delete)
    - Create New button
4. **Resource Create** (`admin::resources.create`)

    - Form with name, email, password, role fields
    - Cancel button
5. **Resource Show** (`admin::resources.show`)

    - Item details in grid layout
    - Edit and Delete buttons
    - Back navigation
6. **Resource Edit** (`admin::resources.edit`)

    - Pre-filled form with existing data
    - Dynamic field generation based on table structure
    - Password field (optional - leave blank to keep current)

Routes
------

[](#routes-1)

### Web Routes

[](#web-routes)

```
// Public (guest only)
GET  /admin/login           - Login form
POST /admin/login           - Login submit

// Protected (auth required)
GET  /admin                 - Dashboard
POST /admin/logout          - Logout
GET  /admin/dashboard       - Dashboard
GET  /admin/resources/{resource}              - List items
GET  /admin/resources/{resource}/create       - Create form
POST /admin/resources/{resource}              - Store item
GET  /admin/resources/{resource}/{id}         - Show item
GET  /admin/resources/{resource}/{id}/edit    - Edit form
PUT  /admin/resources/{resource}/{id}         - Update item
DELETE /admin/resources/{resource}/{id}         - Delete item
GET  /admin/media           - Media management
POST /admin/media           - Media upload
DELETE /admin/media/{id}    - Media delete
GET  /admin/settings        - Settings
PUT  /admin/settings        - Update settings
```

### API Routes

[](#api-routes)

```
GET    /api/admin/resources/{resource}           - API index
POST   /api/admin/resources/{resource}           - API store
GET    /api/admin/resources/{resource}/{id}      - API show
PUT    /api/admin/resources/{resource}/{id}      - API update
DELETE /api/admin/resources/{resource}/{id}      - API delete
```

Middleware
----------

[](#middleware)

### AdminAuthMiddleware

[](#adminauthmiddleware)

Protects routes requiring authentication. Redirects unauthenticated users to `/admin/login`.

Usage:

```
$router->group(['middleware' => \Libxa\Admin\Http\Middleware\AdminAuthMiddleware::class], function ($router) {
    $router->get('/dashboard', [DashboardController::class, 'index']);
});
```

### RedirectIfAuthenticated

[](#redirectifauthenticated)

Redirects authenticated users away from login page.

Usage:

```
$router->group(['middleware' => \Libxa\Admin\Http\Middleware\RedirectIfAuthenticated::class], function ($router) {
    $router->get('/login', function () {
        return view('admin::auth.login');
    });
});
```

Complete Example
----------------

[](#complete-example)

Here's a complete example of using LibAdmin:

### Step 1: Setup

[](#step-1-setup)

```
# Run migrations
php libxa migrate

# Create admin user
php libxa admin:make-user "Admin User" "admin@example.com" "securepass123"

# Start development server
php libxa serve
```

### Step 2: Login

[](#step-2-login)

Navigate to `http://127.0.0.1:8000/admin/login`

- Email: `admin@example.com`
- Password: `securepass123`

### Step 3: Manage Users

[](#step-3-manage-users)

Navigate to `http://127.0.0.1:8000/admin/resources/users`

You can now:

- View all users in a table
- Create new users
- Edit existing users
- Delete users

### Step 4: Manage Any Table

[](#step-4-manage-any-table)

The beauty of LibAdmin is that it works with ANY database table.

If you have a `posts` table, simply navigate to: `http://127.0.0.1:8000/admin/resources/posts`

The interface automatically:

- Detects table columns
- Generates appropriate form fields
- Displays data in a table
- Handles CRUD operations

### Step 5: Create Resources (Optional)

[](#step-5-create-resources-optional)

For advanced customization, create resource classes:

```
php libxa admin:make-resource Product
```

This generates a resource class in your application that you can customize.

Controllers
-----------

[](#controllers)

### AuthController

[](#authcontroller)

```
class AuthController
{
    public function login(Request $request): Response
    {
        $credentials = $request->only(['email', 'password']);
        $remember = $request->input('remember') === 'on';

        if ($this->auth->attempt($credentials, $remember)) {
            return redirect('/admin/dashboard');
        }

        return redirect('/admin/login')->with('error', 'Invalid credentials');
    }

    public function logout(Request $request): Response
    {
        $this->auth->logout();
        return redirect('/admin/login');
    }
}
```

### DashboardController

[](#dashboardcontroller)

```
class DashboardController
{
    public function index(): Response
    {
        $user = $this->auth->user();
        return view('admin::dashboard', compact('user'));
    }
}
```

### ResourceController

[](#resourcecontroller)

Dynamic CRUD controller that works with any table:

```
class ResourceController
{
    public function index(string $resource): Response
    {
        $items = DB::table($resource)->get();
        return view('admin::resources.index', compact('resource', 'items'));
    }

    public function store(Request $request, string $resource): Response
    {
        // Automatically filters columns and hashes passwords
        $filteredData = $this->filterData($resource, $request->all());
        DB::table($resource)->insert($filteredData);
        return redirect("/admin/resources/$resource");
    }
}
```

Customization
-------------

[](#customization)

### Customizing the Layout

[](#customizing-the-layout)

Edit `packages/lib-admin/src/Resources/views/layouts/admin.blade.php` to customize:

- Sidebar navigation
- Header styling
- Color scheme
- Logo

### Customizing Forms

[](#customizing-forms)

Edit the resource views in `packages/lib-admin/src/Resources/views/resources/`:

- `create.blade.php` - Customize create form
- `edit.blade.php` - Customize edit form
- `index.blade.php` - Customize table view
- `show.blade.php` - Customize detail view

Security Features
-----------------

[](#security-features)

- **Password Hashing** - Automatic bcrypt hashing for passwords
- **Session Management** - Secure session-based authentication
- **Route Protection** - Middleware guards for protected routes
- **Input Filtering** - Filters data to match table columns (prevents SQL errors)
- **CSRF Protection** - Framework-level CSRF protection

Troubleshooting
---------------

[](#troubleshooting)

### "No commands defined in 'admin' namespace"

[](#no-commands-defined-in-admin-namespace)

Run package discovery:

```
php libxa package:discover
```

### "Table has no column named X"

[](#table-has-no-column-named-x)

The ResourceController automatically filters fields to match table columns. Extra form fields are ignored. This is normal behavior.

### Can't access admin panel

[](#cant-access-admin-panel)

1. Ensure you've run migrations: `php libxa migrate`
2. Create an admin user: `php libxa admin:make-user`
3. Check that the server is running: `php libxa serve`
4. Navigate to `/admin/login` (not `/admin`)

Package Structure
-----------------

[](#package-structure)

```
packages/lib-admin/
├── src/
│   ├── AdminServiceProvider.php      # Service provider
│   ├── Models/
│   │   └── AdminUser.php            # User model
│   ├── Auth/
│   │   ├── AdminGuard.php           # Authentication guard
│   │   └── AdminUserProvider.php    # User provider
│   ├── Http/
│   │   ├── Controllers/
│   │   │   ├── AuthController.php
│   │   │   ├── DashboardController.php
│   │   │   └── ResourceController.php
│   │   └── Middleware/
│   │       ├── AdminAuthMiddleware.php
│   │       └── RedirectIfAuthenticated.php
│   ├── Console/Commands/
│   │   ├── MakeUserCommand.php
│   │   ├── MakeResourceCommand.php
│   │   └── RolesCommand.php
│   ├── Routes/
│   │   ├── web.php
│   │   └── api.php
│   ├── Resources/views/
│   │   ├── layouts/
│   │   │   └── admin.blade.php      # Shared layout
│   │   ├── auth/
│   │   │   └── login.blade.php
│   │   ├── dashboard.blade.php
│   │   └── resources/
│   │       ├── index.blade.php
│   │       ├── create.blade.php
│   │       ├── show.blade.php
│   │       └── edit.blade.php
│   └── Database/Migrations/         # Package migrations
└── composer.json

```

License
-------

[](#license)

Part of the LibxaFrame framework.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance88

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

60d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/771945f7f27a8c282d08a644818b7a38d2d972ca0de5b46a10e9092fd8d87278?d=identicon)[voukengdongmofrankysteve](/maintainers/voukengdongmofrankysteve)

---

Top Contributors

[![voukengdongmofrankysteve](https://avatars.githubusercontent.com/u/73015346?v=4)](https://github.com/voukengdongmofrankysteve "voukengdongmofrankysteve (6 commits)")

### Embed Badge

![Health badge](/badges/libxa-lib-admin/health.svg)

```
[![Health](https://phpackages.com/badges/libxa-lib-admin/health.svg)](https://phpackages.com/packages/libxa-lib-admin)
```

###  Alternatives

[leung/laravel-adminer

adminer for laravel5.\*

169.0k](/packages/leung-laravel-adminer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
