wsmallnews/category
Composer 安装命令:
composer require wsmallnews/category
包简介
Wsmallnews system classify/category modules
关键字:
README 文档
README
wsmallnews/category is a Filament category management package built on wsmallnews/filament-nestedset. It provides hierarchical categories, category type management, scopeable data, and optional Filament tenancy support.
Features
- Category tree management powered by
kalnoy/nestedsetthroughwsmallnews/filament-nestedset - Category type records for separating different category trees
- Scopeable category data via
scope_typeandscope_id - Automatic tenant scoping when the current Filament panel supports tenancy
- Filament plugin registration for category pages and category type resources
- Frontend Livewire category tree component
AI Guidelines
This package ships Laravel Boost AI Guidelines in resources/boost/guidelines/core.blade.php.
Install or enable Laravel Boost in your application, then refresh Boost resources so this package's guidelines are discovered and added to the project overview:
php artisan boost:update --discover
Boost updates the root boost.json and CLAUDE.md automatically. Check those files after running the command to confirm wsmallnews/category is included.
Installation
You can install the package via composer:
composer require wsmallnews/category
The package provides an install command. By default it also installs its support dependency:
php artisan sn-category:install
To skip dependency installation and interactive prompts:
php artisan sn-category:install --no-deps --no-interaction
You can publish and run only the migrations with:
php artisan vendor:publish --tag="category-migrations"
php artisan migrate
You can publish only the config file with:
php artisan vendor:publish --tag="category-config"
Optionally, you can publish the views using:
php artisan vendor:publish --tag="category-views"
Configuration
The package configuration lives in config/sn-category.php:
return [ 'scopeable' => [ 'scope_type' => 'sn-category', 'scope_id' => 0, ], 'models' => [ 'category' => Wsmallnews\Category\Models\Category::class, 'category_type' => Wsmallnews\Category\Models\CategoryType::class, ], 'panel_register' => [ 'pages' => [ Wsmallnews\Category\Filament\Pages\Category\CategoryPage::class, ], 'resources' => [ Wsmallnews\Category\Filament\Resources\CategoryTypes\CategoryTypeResource::class, ], ], ];
Filament plugin
Register the plugin on your Filament panel:
use Wsmallnews\Category\CategoryPlugin; $panel ->plugin(CategoryPlugin::make());
CategoryPlugin registers the pages and resources configured in sn-category.panel_register:
Wsmallnews\Category\Filament\Pages\Category\CategoryPageWsmallnews\Category\Filament\Resources\CategoryTypes\CategoryTypeResource
Usage
Category page
CategoryPage extends Wsmallnews\Category\Filament\Pages\Category\Base, which extends Wsmallnews\FilamentNestedset\Filament\Pages\NestedsetPage.
The base page automatically resolves or creates a CategoryType for the configured scope, applies the type's level to the nestedset tree, and scopes category records by:
scope_typescope_idtype_idteam_idwhen tenancy is enabled
Custom category page
Create your own page by extending the base page:
<?php namespace App\Filament\Pages; use Wsmallnews\Category\Filament\Pages\Category\Base; class ProductCategories extends Base { protected static ?string $slug = 'product-categories'; protected static ?string $scopeType = 'product'; protected static int $scopeId = 0; protected static ?int $level = 3; }
Category model
Wsmallnews\Category\Models\Category uses Kalnoy\Nestedset\NodeTrait and defines scope attributes for nestedset scoping:
public function getScopeAttributes(): array { return ['scope_type', 'scope_id', 'type_id', 'team_id']; }
When tenancy is disabled, team_id is not added to the scope attributes.
Frontend component
The service provider registers the category tree Livewire component as:
<livewire:sn-category-components-categories />
Use the component when you need a frontend category tree display that follows the package conventions.
Namespace Quick Reference
| Category | Namespace |
|---|---|
| Plugin | Wsmallnews\Category\CategoryPlugin |
| ServiceProvider | Wsmallnews\Category\CategoryServiceProvider |
| Page Base | Wsmallnews\Category\Filament\Pages\Category\Base |
| Page Implementation | Wsmallnews\Category\Filament\Pages\Category\CategoryPage |
| Page Widget | Wsmallnews\Category\Filament\Pages\Category\Widgets\Category |
| Category Type Resource | Wsmallnews\Category\Filament\Resources\CategoryTypes\CategoryTypeResource |
| Category Model | Wsmallnews\Category\Models\Category |
| Category Type Model | Wsmallnews\Category\Models\CategoryType |
| Frontend Component | Wsmallnews\Category\Livewire\Components\Categories |
| Install Command | Wsmallnews\Category\Commands\CategoryInstallCommand |
| Utils | Wsmallnews\Category\Support\Utils |
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
wsmallnews/category 适用场景与选型建议
wsmallnews/category 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「category」 「laravel」 「Wsmallnews」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wsmallnews/category 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wsmallnews/category 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wsmallnews/category 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Filament nestedset tree builder powered by kalnoy/nestedset with Filament v4 and v5 support
Display your categories and products on front end of your website
taxonomy term implementation in php
taxonomy term implementation in Yii2
Ready to use blog package
Node categories model and observer for laravel 5
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-01