tourze / cms-bundle
CMS内容管理系统核心功能包
Installs: 78
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/cms-bundle
Requires
- php: ^8.1
- doctrine/collections: ^2.3
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/doctrine-fixtures-bundle: ^4.0
- doctrine/orm: ^3.0
- doctrine/persistence: ^3.1 || ^4
- knplabs/knp-menu: ^3.7
- nesbot/carbon: ^2.72 || ^3
- psr/log: ^3|^2|^1
- symfony/cache: ^6.4
- symfony/cache-contracts: ^3
- symfony/config: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/doctrine-bridge: ^6.4
- symfony/event-dispatcher: ^6.4
- symfony/event-dispatcher-contracts: ^2.5 | ^3
- symfony/framework-bundle: ^6.4
- symfony/http-foundation: ^6.4
- symfony/http-kernel: ^6.4
- symfony/lock: ^6.4
- symfony/messenger: ^6.4
- symfony/property-access: ^6.4
- symfony/routing: ^6.4
- symfony/security-bundle: ^6.4
- symfony/security-core: ^6.4
- symfony/security-http: ^6.4
- symfony/serializer: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/arrayable: 0.0.*
- tourze/bundle-dependency: 0.0.*
- tourze/doctrine-async-insert-bundle: 0.1.*
- tourze/doctrine-entity-lock-bundle: 0.0.*
- tourze/doctrine-helper: 0.0.*
- tourze/doctrine-indexed-bundle: 0.0.*
- tourze/doctrine-ip-bundle: 0.0.*
- tourze/doctrine-snowflake-bundle: 0.1.*
- tourze/doctrine-timestamp-bundle: 0.0.*
- tourze/doctrine-track-bundle: 0.1.*
- tourze/doctrine-user-bundle: 0.0.*
- tourze/easy-admin-attribute: 0.1.*
- tourze/easy-admin-menu-bundle: 0.1.*
- tourze/enum-extra: 0.1.*
- tourze/json-rpc-cache-bundle: 0.1.*
- tourze/json-rpc-core: 0.0.*
- tourze/json-rpc-lock-bundle: 0.1.*
- tourze/json-rpc-log-bundle: 0.1.*
- tourze/json-rpc-paginator-bundle: 0.0.*
- tourze/lock-service-bundle: 0.1.*
- tourze/symfony-aop-async-bundle: 0.0.*
- tourze/symfony-routing-auto-loader-bundle: 0.0.*
- tourze/user-event-bundle: 0.0.*
- tourze/user-id-bundle: 0.1.*
- twig/twig: ^3.13|^4.0
- yiisoft/arrays: ^3
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-10-31 19:53:24 UTC
README
A comprehensive CMS (Content Management System) bundle for Symfony applications, providing content management, category organization, tagging, and statistics features.
Table of Contents
- Features
- Installation
- Configuration
- Usage
- Database Schema
- Advanced Usage
- Testing
- Requirements
- Contributing
- License
Features
- Content Management: Entity-Attribute-Value (EAV) based content model
- Category System: Hierarchical content categorization
- Tag Management: Flexible tagging system with tag groups
- Search & Statistics: Content search logs and visit statistics
- Event System: Content collection, liking, and visit tracking
- JSON-RPC API: RESTful API endpoints for content operations
- Admin Interface: EasyAdmin integration for backend management
- Twig Extensions: Template helpers for CMS functionality
Installation
composer require tourze/cms-bundle
Configuration
Add the bundle to your config/bundles.php:
return [ // ... CmsBundle\CmsBundle::class => ['all' => true], ];
Usage
Basic Entity Structure
The bundle provides 6 core entities:
- Category: Hierarchical content categorization with tree structure
- SearchLog: Search history tracking and keyword analytics
- Tag: Content tagging system with unique tag names
- TagGroup: Organization and grouping of tags
- Topic: Content topics/articles with recommendation support
- VisitStat: Daily visit statistics tracking
Services
ContentService
Search content by keywords in EAV attributes:
use CmsBundle\Service\ContentService; class YourController { public function __construct( private ContentService $contentService ) {} public function searchContent(string $keyword): void { $queryBuilder = $this->entityManager->createQueryBuilder(); $this->contentService->searchByKeyword($queryBuilder, $keyword); } }
StatService
Update visit statistics asynchronously:
use CmsBundle\Service\StatService; class YourController { public function __construct( private StatService $statService ) {} public function updateStats(int $entityId): void { $this->statService->updateStat($entityId); } }
JSON-RPC Procedures
The bundle provides JSON-RPC endpoints for:
Content Operations
- GetCmsEntityList: Retrieve paginated content lists with category/model filtering
- GetCmsEntityDetail: Get detailed content information with visit tracking
Category Management
- GetCmsCategoryList: Fetch category listings by model
- GetCmsCategoryDetail: Get category details
- AdminCreateCmsCategory: Create new categories (admin)
- AdminGetCmsCategoryList: Admin category management
- AdminGetCmsCategoryTree: Hierarchical category tree structure
Events
The bundle dispatches events for content interactions:
- CollectEntityEvent: When content is collected/bookmarked
- LikeEntityEvent: When content is liked
- VisitEntityEvent: When content is visited
Twig Extensions
Use CMS functionality in templates:
{# Get single entity detail #}
{% set entity = get_cms_entity_detail(123) %}
{{ entity.title }}
{# Get entity list by model #}
{% set entities = get_cms_entity_list('article', 10, 0) %}
{% for entity in entities %}
    <h2>{{ entity.title }}</h2>
{% endfor %}
Database Schema
The bundle creates the following tables:
- cms_category: Hierarchical content categories with tree structure
- ims_cms_search: Search history logs with keyword tracking
- cms_tag: Content tags with unique names
- cms_tag_group: Tag organization groups
- cms_topic: Content topics with recommendation support
- cms_visit_stat: Daily visit statistics
Advanced Usage
Custom Entity Models
Extend the EAV model system for custom content types:
use CmsBundle\Service\EntityService;use CmsBundle\Service\ModelService; class CustomContentService { public function __construct( private ModelService $modelService, private EntityService $entityService ) {} public function createCustomEntity(string $modelCode, array $data): Entity { $model = $this->modelService->findValidModelByCode($modelCode); // Create and populate entity... } }
Advanced Search Integration
Implement complex search scenarios using ContentService:
use CmsBundle\Service\ContentService; $qb = $entityRepository->createQueryBuilder('e'); $this->contentService->searchByKeyword($qb, 'search term', $model); $results = $qb->getQuery()->getResult();
Cross-Module Integration
When integrating with other modules, always use Service layer instead of direct Repository access:
// ✅ Correct - Use Service layer $entityService->findEntityBy(['id' => $id]); // ❌ Wrong - Direct Repository access violates architecture $entityRepository->findOneBy(['id' => $id]);
Testing
Run the test suite:
./vendor/bin/phpunit packages/cms-bundle/tests
Requirements
- PHP 8.1+
- Symfony 6.4+
- Doctrine ORM 3.0+
Contributing
Contributions are welcome! Please read our contributing guidelines and submit pull requests.
License
MIT License