tourze/hotel-profile-bundle
Composer 安装命令:
composer require tourze/hotel-profile-bundle
包简介
酒店档案管理模块,提供酒店信息和房型管理功能
README 文档
README
[]
(https://packagist.org/packages/tourze/hotel-profile-bundle)
[
]
(https://packagist.org/packages/tourze/hotel-profile-bundle)
Hotel profile management bundle for Symfony applications. This bundle provides comprehensive hotel and room type management functionality with administrative interfaces, Excel import/export capabilities, and EasyAdmin integration.
Note: This is an internal package for the monorepo architecture and is not published to Packagist.
Table of Contents
- Features
- Installation
- Quick Start
- Requirements
- Configuration
- Entities
- Services
- Enums
- Admin Interface
- API Endpoints
- Advanced Usage
- Testing
- Contributing
- License
- Support
Features
- Hotel Management: Complete CRUD operations for hotel profiles
- Room Type Management: Room type configurations for each hotel
- Excel Import/Export: Bulk import and export hotel data via Excel files
- EasyAdmin Integration: Ready-to-use administrative interface
- Status Management: Hotel operational status tracking
- Validation: Comprehensive data validation with Symfony constraints
- Audit Trail: Automatic timestamp tracking for all entities
Installation
Step 1: Monorepo Usage
This bundle is designed for use within the monorepo architecture. It's automatically available when you set up the monorepo project.
Step 2: Enable the Bundle
The bundle is automatically registered in the Symfony kernel. You can verify it's enabled by checking:
bin/console debug:container --tag=kernel.bundles
Step 3: Update Database Schema
php bin/console doctrine:migrations:diff php bin/console doctrine:migrations:migrate
Step 4: Verify Installation
# Check if hotel-related routes are available bin/console debug:router | grep hotel # Check if services are registered bin/console debug:container HotelService
Quick Start
Basic Usage
<?php use Tourze\HotelProfileBundle\Entity\Hotel; use Tourze\HotelProfileBundle\Enum\HotelStatusEnum; use Tourze\HotelProfileBundle\Service\HotelService; // Create a new hotel $hotel = new Hotel(); $hotel->setName('Grand Hotel'); $hotel->setAddress('123 Main Street'); $hotel->setStarLevel(5); $hotel->setContactPerson('John Doe'); $hotel->setPhone('+1234567890'); $hotel->setStatus(HotelStatusEnum::OPERATING); // Use the hotel service $hotelService = $container->get(HotelService::class); // Find hotels by status $operatingHotels = $hotelService->findHotelsByStatus(HotelStatusEnum::OPERATING); // Update hotel status $hotelService->updateHotelStatus($hotelId, HotelStatusEnum::SUSPENDED);
Requirements
- PHP 8.1+
- Symfony 7.3+
- Doctrine ORM 3.0+
- EasyAdmin Bundle 4+
- Doctrine DBAL 4.0+
- PHPSpreadsheet for Excel operations
Configuration
The bundle requires minimal configuration. After installation, it automatically registers all necessary services.
Entities
Hotel Entity
The Hotel entity includes:
- Basic information (name, address, contact details)
- Star rating (1-5 stars)
- Photo gallery (JSON array of URLs)
- Facilities information (JSON array)
- Operational status
- One-to-many relationship with room types
Room Type Entity
The RoomType entity includes:
- Room type details and pricing
- Availability status
- Association with hotel
Services
HotelService
Core business service for hotel operations:
use Tourze\HotelProfileBundle\Service\HotelService; // Find hotels by status $operatingHotels = $hotelService->findHotelsByStatus(HotelStatusEnum::OPERATING); // Update hotel status $hotelService->updateHotelStatus($hotelId, HotelStatusEnum::SUSPENDED);
RoomTypeService
Room type management service:
use Tourze\HotelProfileBundle\Service\RoomTypeService; // Find room types by hotel $roomTypes = $roomTypeService->findRoomTypesByHotel($hotelId); // Find room types by status $activeRoomTypes = $roomTypeService->findRoomTypesByStatus(RoomTypeStatusEnum::ACTIVE);
HotelImportExportService
Excel import/export functionality:
use Tourze\HotelProfileBundle\Service\HotelImportExportService; // Export hotels to Excel $exportResult = $importExportService->exportHotelsToExcel(); // Create import template $template = $importExportService->createImportTemplate(); // Import hotels from Excel $importResult = $importExportService->importHotelsFromExcel($uploadedFile);
Enums
HotelStatusEnum
Hotel operational status:
OPERATING: Hotel is currently operatingSUSPENDED: Hotel cooperation is suspended
RoomTypeStatusEnum
Room type availability status:
ACTIVE: Room type is available for bookingDISABLED: Room type is temporarily disabled
Admin Interface
The bundle provides EasyAdmin CRUD controllers:
- Hotel management at
/admin/hotel - Room type management at
/admin/room-type - Import/export functionality in admin interface
API Endpoints
Administrative API endpoints are available for:
- Room type management
- Hotel data operations
Advanced Usage
Custom Validation Rules
You can extend the bundle's validation by creating custom validators:
use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; class CustomHotelValidator extends ConstraintValidator { public function validate($value, Constraint $constraint): void { // Custom validation logic } }
Event Listeners
Listen to hotel-related events:
use Symfony\Component\EventDispatcher\EventSubscriberInterface; class HotelEventSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents(): array { return [ 'hotel.created' => 'onHotelCreated', 'hotel.updated' => 'onHotelUpdated', ]; } public function onHotelCreated(HotelEvent $event): void { // Handle hotel creation } }
Custom Export Formats
Extend the import/export service to support additional formats:
use Tourze\HotelProfileBundle\Service\HotelImportExportService; class CustomImportExportService extends HotelImportExportService { public function exportToCsv(): Response { // Custom CSV export logic } }
Data Fixtures
Sample data fixtures are provided for testing:
HotelFixtures: Sample hotel dataRoomTypeFixtures: Sample room type configurations
Testing
The bundle includes comprehensive test coverage:
# Run all tests vendor/bin/phpunit packages/hotel-profile-bundle/tests # Run specific test categories vendor/bin/phpunit packages/hotel-profile-bundle/tests/Entity vendor/bin/phpunit packages/hotel-profile-bundle/tests/Service vendor/bin/phpunit packages/hotel-profile-bundle/tests/Controller # Run with coverage vendor/bin/phpunit packages/hotel-profile-bundle/tests --coverage-html coverage/ # Run static analysis vendor/bin/phpstan analyse packages/hotel-profile-bundle
Contributing
We welcome contributions to this bundle! Here's how you can help:
Reporting Issues
If you find a bug or have a feature request, please create an issue on our GitHub repository.
Submitting Pull Requests
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests:
vendor/bin/phpunit packages/hotel-profile-bundle/tests - Run static analysis:
vendor/bin/phpstan analyse packages/hotel-profile-bundle - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Code Standards
- Follow PSR-12 coding standards
- Add PHPDoc comments for all public methods
- Write unit tests for new features
- Ensure backward compatibility
License
This bundle is open-sourced software licensed under the MIT License. Please see the LICENSE file for more information.
Support
For issues and feature requests, please use the GitHub issue tracker.
tourze/hotel-profile-bundle 适用场景与选型建议
tourze/hotel-profile-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 455 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tourze/hotel-profile-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tourze/hotel-profile-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 455
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-23