tasmir/sidebar-manager
Composer 安装命令:
composer require tasmir/sidebar-manager
包简介
A flexible, dynamic sidebar management package for Laravel applications. This package allows you to define, manipulate, and render your sidebar navigation entirely through code or configuration.
README 文档
README
A flexible, dynamic sidebar management package for Laravel applications. This package allows you to define, manipulate, and render your sidebar navigation entirely through code or configuration.
Features
- Fluent API: Expressive and easy registration of menu items.
- Facade Support: Use the
Sidebarfacade for clean, static-like access. - Config Driven: Define your core sidebar structure in
config/sidebar.php. - Dynamic Manipulation: Add or modify categories and items at runtime.
- Permission Based: Built-in support for Laravel's Gate/Permission system.
- Blade Component: Clean rendering using a single
<x-sidebar-manager-nav />component. - Badges: Support for static or dynamic (callable) badges.
- Active State Detection: Automatic highlighting of active menu items.
Installation
You can install the package via composer:
composer require tasmir/sidebar-manager
Publish the config file (optional):
php artisan vendor:publish --tag="config"
Basic Usage
1. Rendering the Sidebar
Place the Blade component in your layout:
<x-sidebar-manager-nav />
2. Static Configuration
You can define your menu in config/sidebar.php. You can also remove default categories or specific items:
return [ 'menu' => [ 'marketing' => [ 'category' => 'Marketing', 'order' => 50, 'items' => [ 'campaigns' => [ 'label' => 'Campaigns', 'route' => 'admin.marketing.campaigns', 'icon' => '<svg>...</svg>', 'permission' => 'campaigns_list', ], ], ], ], // Remove default items or categories 'remove' => [ 'dashboard', // Removes the entire dashboard category 'system' => ['activity'], // Removes only the 'activity' item from 'system' ], ];
3. Fluent API (via Facade)
You can manipulate the sidebar from anywhere (e.g., controllers, closures, or providers) using the Sidebar facade:
use Sidebar; // Add a category Sidebar::category('settings', [ 'category' => 'Settings', 'order' => 100, ]); // Add an item fluently Sidebar::item('settings', 'profile', [ 'label' => 'My Profile', 'route' => 'admin.profile.edit', 'icon' => '<svg>...</svg>', ]); // Extending an existing group from another module Sidebar::item('marketing', 'newsletter', [ 'label' => 'Newsletter', 'route' => 'admin.marketing.newsletter', 'icon' => '<svg>...</svg>', 'order' => 10, // Items will be sorted by this order ]); // Remove an item Sidebar::removeItem('system', 'activity'); // Remove an entire category Sidebar::removeCategory('dashboard');
4. Blade Directives
You can also manage the sidebar directly from your Blade templates for view-specific adjustments:
{{-- Add a category --}} @addSidebarCategory('reports', ['category' => 'Reports', 'order' => 60]) {{-- Add an item to a category --}} @addSidebarItem('reports', 'sales', [ 'label' => 'Sales Report', 'route' => 'admin.reports.sales', 'icon' => '<svg>...</svg>' ]) {{-- Remove items or categories --}} @removeSidebarItem('system', 'activity') @removeSidebarCategory('dashboard') {{-- Finally, render the sidebar --}} <x-sidebar-manager-nav />
Menu Item Configuration
Each item accepts a configuration array:
| Key | Type | Description |
|---|---|---|
label |
string |
Display text. |
route |
string |
Laravel route name. |
url |
string |
Fallback URL. |
params |
array |
Route parameters. |
icon |
string |
Raw HTML/SVG for the icon. |
active |
bool |
Active state logic. |
permission |
string |
Required permission. |
badge |
int|Closure |
Static number or closure. |
order |
int |
Sort position. |
Contributing
Contributions are welcome! If you have any ideas, bug fixes, or improvements, feel free to open an issue or submit a pull request on GitHub.
Developed by Tasmir
License
The MIT License (MIT). Please see License File for more information.
tasmir/sidebar-manager 适用场景与选型建议
tasmir/sidebar-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tasmir/sidebar-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tasmir/sidebar-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-10