tourze / tag-manage-bundle
通用标签管理
Installs: 572
Dependents: 6
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/tag-manage-bundle
Requires
- doctrine/collections: ^2.3
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- doctrine/persistence: ^4.1
- easycorp/easyadmin-bundle: ^4
- knplabs/knp-menu: ^3.7
- nesbot/carbon: ^2.72 || ^3
- symfony/config: ^7.3
- symfony/console: ^7.3
- symfony/dependency-injection: ^7.3
- symfony/doctrine-bridge: ^7.3
- symfony/event-dispatcher: ^7.3
- symfony/framework-bundle: ^7.3
- symfony/http-foundation: ^7.3
- symfony/http-kernel: ^7.3
- symfony/property-access: ^7.3
- symfony/serializer: ^7.3
- symfony/service-contracts: ^3.6
- symfony/yaml: ^7.3
- tourze/bundle-dependency: 1.*
- tourze/doctrine-indexed-bundle: 1.0.*
- tourze/doctrine-ip-bundle: 1.1.*
- tourze/doctrine-snowflake-bundle: 1.1.*
- tourze/doctrine-timestamp-bundle: 1.1.*
- tourze/doctrine-track-bundle: 1.1.*
- tourze/doctrine-user-bundle: 1.0.*
- tourze/easy-admin-menu-bundle: 1.0.*
- tourze/enum-extra: 1.0.*
- tourze/json-rpc-cache-bundle: 1.0.*
- tourze/json-rpc-core: 1.0.*
- tourze/json-rpc-paginator-bundle: 1.0.*
- tourze/symfony-dependency-service-loader: 1.0.*
Requires (Dev)
This package is auto-updated.
Last update: 2025-11-18 15:23:56 UTC
README
A comprehensive tag management system for Symfony, providing complete tag and tag group management features with EasyAdmin backend integration and JsonRPC API support.
Features
- � Tag Management: Create, edit, delete tags with unique name validation
- � Tag Groups: Organize tags into groups for better management
- � EasyAdmin Integration: Complete backend management interface
- � JsonRPC API: Rich API interface support
- � Cache Support: Automatic API result caching for performance
- � Pagination: Tag list pagination and filtering
- � Audit Fields: Automatic tracking of creation/update time and users
- � Soft Delete: Tag validity status management
- � Search: Keyword-based tag search functionality
Requirements
- PHP 8.1+
- Symfony 7.3+
- Doctrine ORM 3.0+
Installation
Install using Composer:
composer require tourze/tag-manage-bundle
Configuration
1. Register Bundle
Register in config/bundles.php:
return [ // ... Tourze\TagManageBundle\TagManageBundle::class => ['all' => true], ];
2. Database Migration
Bundle automatically creates the following database tables:
cms_tag: Tags tablecms_tag_group: Tag groups table
Run database migration:
php bin/console doctrine:migrations:migrate
3. Load Fixtures (Optional)
To load test data:
php bin/console doctrine:fixtures:load --group=tag
Usage
1. Entity Usage
use Tourze\TagManageBundle\Entity\Tag; use Tourze\TagManageBundle\Entity\TagGroup; // Create tag group $group = new TagGroup(); $group->setName('Technology'); // Create tag $tag = new Tag(); $tag->setName('PHP'); $tag->setGroups($group); $tag->setValid(true);
2. EasyAdmin Backend Management
Bundle automatically registers backend management routes:
- Tag Management:
/admin/cms/tag - Tag Group Management:
/admin/cms/tag-group
3. JsonRPC API Usage
Get Tag List
{
"jsonrpc": "2.0",
"method": "GetTagList",
"params": {
"groupId": "group_id",
"keyword": "search keyword",
"validOnly": true,
"orderBy": "createTime",
"orderDir": "DESC",
"includeUsageStats": true
},
"id": 1
}
Get Tag Group List
{
"jsonrpc": "2.0",
"method": "GetTagGroupList",
"params": {
"orderBy": "name",
"orderDir": "ASC"
},
"id": 2
}
Get Tag Group Detail
{
"jsonrpc": "2.0",
"method": "GetTagGroupDetail",
"params": {
"id": "group_id",
"includeTags": true
},
"id": 3
}
Search Tags
{
"jsonrpc": "2.0",
"method": "SearchTags",
"params": {
"keyword": "PHP",
"groupId": "group_id",
"validOnly": true
},
"id": 4
}
4. Repository Queries
use Tourze\TagManageBundle\Repository\TagRepository; use Tourze\TagManageBundle\Repository\TagGroupRepository; // Tag queries $tags = $tagRepository->findBy(['valid' => true], ['name' => 'ASC']); $tag = $tagRepository->findOneBy(['name' => 'PHP']); // Tag group queries $groups = $tagGroupRepository->findAll(); $group = $tagGroupRepository->findOneBy(['name' => 'Technology']);
Configuration Options
Configure in config/packages/tag_manage.yaml:
tag_manage: # Cache duration in seconds, default 600 cache_duration: 600 # Default page size, default 20 default_page_size: 20 # Enable usage statistics, default false enable_usage_stats: false
Entity Fields
Tag
| Field | Type | Description |
|---|---|---|
| id | integer | Primary key ID |
| name | string(60) | Tag name (unique) |
| groups | TagGroup | Belonging tag group |
| valid | boolean | Valid status |
| createTime | datetime | Creation time |
| updateTime | datetime | Update time |
| createUser | string | Creation user |
| updateUser | string | Update user |
TagGroup
| Field | Type | Description |
|---|---|---|
| id | string | Snowflake ID primary key |
| name | string(60) | Group name |
| createTime | datetime | Creation time |
| updateTime | datetime | Update time |
| createUser | string | Creation user |
| updateUser | string | Update user |
API Response Format
List Interface Response
{
"jsonrpc": "2.0",
"result": {
"list": [
{
"id": 1,
"name": "PHP",
"valid": true,
"group": {
"id": "1234567890123456789",
"name": "Technology"
},
"createTime": "2024-01-01 12:00:00",
"updateTime": "2024-01-01 12:00:00",
"usageCount": 156,
"lastUsedTime": "2024-01-15 10:30:00"
}
],
"pagination": {
"current": 1,
"pageSize": 20,
"total": 100,
"hasMore": true
}
},
"id": 1
}
Testing
Run the test suite:
# Run all tests php bin/console phpunit tests/TagManageBundle/ # Run specific tests php bin/console phpunit tests/TagManageBundle/Entity/TagTest.php # Run coverage test php bin/console phpunit --coverage-html coverage tests/TagManageBundle/
Dependencies
Bundle depends on the following key packages:
- EasyAdminBundle: Backend management interface
- Doctrine ORM: Data persistence
- JsonRPC Core: API interface support
- JsonRPC Cache: API caching functionality
- JsonRPC Paginator: Pagination functionality
- Doctrine Timestamp Bundle: Timestamp fields
- Doctrine User Bundle: User audit fields
- Doctrine IP Bundle: IP audit fields
Changelog
1.0.0
- Initial release
- Tag and tag group management support
- EasyAdmin backend integration
- JsonRPC API interface
- Cache and pagination support
Contributing
Issues and Pull Requests are welcome!
License
MIT License