1. Go to this page and download the library: Download shopper/sidebar library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shopper / sidebar example snippets
// In a route group
Route::middleware(['web', \Shopper\Sidebar\Middleware\ResolveSidebars::class])
->group(function () {
// Your routes
});
// Or in bootstrap/app.php (Laravel 11+)
->withMiddleware(function (Middleware $middleware) {
$middleware->appendToGroup('web', [
\Shopper\Sidebar\Middleware\ResolveSidebars::class,
]);
})
namespace App\Sidebar;
use Shopper\Sidebar\Contracts\Builder\Menu;
use Shopper\Sidebar\Contracts\Sidebar;
class AdminSidebar implements Sidebar
{
public function __construct(private Menu $menu) {}
public function build(): void
{
$this->menu->group('Main', function ($group) {
$group->item('Dashboard')
->url('/dashboard')
->icon('heroicon-o-home')
->weight(1);
$group->item('Users')
->url('/users')
->icon('heroicon-o-users')
->weight(2)
->items(function ($items) {
$items->item('All Users')->url('/users');
$items->item('Create User')->url('/users/create');
});
});
$this->menu->group('Settings', function ($group) {
$group->item('General')
->url('/settings')
->icon('heroicon-o-cog');
});
}
public function getMenu(): Menu
{
return $this->menu;
}
}
namespace App\Providers;
use App\Sidebar\AdminSidebar;
use Illuminate\Support\ServiceProvider;
use Shopper\Sidebar\SidebarManager;
class SidebarServiceProvider extends ServiceProvider
{
public function boot(SidebarManager $manager): void
{
$manager->register(AdminSidebar::class);
}
}
\Shopper\Sidebar\sidebar_config($key, $default) // Get config value
\Shopper\Sidebar\sidebar_width() // Get sidebar width
\Shopper\Sidebar\sidebar_collapsed_width() // Get collapsed width
\Shopper\Sidebar\sidebar_breakpoint() // Get responsive breakpoint
\Shopper\Sidebar\sidebar_is_collapsible() // Check if collapsible
$group->item('Label')
->url('/path') // URL
->route('route.name') // Or use route name
->icon('heroicon-o-home') // Icon (Blade UI Kit format)
->weight(1) // Sort order
->badge('New') // Add badge
->newTab() // Open in new tab
->authorize(fn() => auth()->check()) // Authorization callback
->items(function ($items) { // Sub-items
$items->item('Sub Item')->url('/sub');
});