tourze / aliyun-vod-bundle
阿里云VOD视频点播服务集成Bundle
Installs: 232
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/aliyun-vod-bundle
Requires
- php: ^8.1
- ext-mbstring: *
- alibabacloud/darabonba-openapi: ^0.2.14
- alibabacloud/vod-20170321: ^3.7
- doctrine/data-fixtures: ^2.0
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/doctrine-fixtures-bundle: ^4.0
- doctrine/orm: ^3.0
- doctrine/persistence: ^3.1 || ^4
- easycorp/easyadmin-bundle: ^4
- psr/log: ^3|^2|^1
- symfony/config: ^6.4
- symfony/console: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/doctrine-bridge: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-foundation: ^6.4
- symfony/http-kernel: ^6.4
- symfony/routing: ^6.4
- symfony/security-core: ^6.4
- symfony/serializer: ^6.4
- symfony/validator: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/bundle-dependency: 0.0.*
- tourze/doctrine-timestamp-bundle: 0.0.*
- tourze/symfony-routing-auto-loader-bundle: 0.0.*
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-11-13 17:52:46 UTC
README
Table of Contents
- Installation
- Configuration
- Console Commands
- Usage Examples
- Advanced Usage
- Admin Interface
- API Endpoints
- Security
- Requirements
- License
- Contributing
- Support
A Symfony bundle for integrating with Alibaba Cloud Video on Demand (VOD) services. This bundle provides comprehensive video management features including upload, transcoding, playback, and statistics.
Features
- Video Management: Upload, update, and manage videos in Alibaba Cloud VOD
- Transcoding: Handle video transcoding tasks and monitor progress
- Playback Statistics: Track video playback data and generate reports
- Admin Interface: EasyAdmin integration for video management
- Console Commands: Powerful CLI tools for video operations
Installation
composer require tourze/aliyun-vod-bundle
Configuration
Add the bundle to your config/bundles.php:
return [ // ... Tourze\AliyunVodBundle\AliyunVodBundle::class => ['all' => true], ];
Configure your Alibaba Cloud credentials in your environment variables or configuration files.
Console Commands
Video Data Synchronization
aliyun-vod:sync:from-remote
Synchronize video data from Alibaba Cloud VOD to local database.
# Sync all videos from all configurations bin/console aliyun-vod:sync:from-remote # Sync from specific configuration bin/console aliyun-vod:sync:from-remote --config=default # Limit sync quantity bin/console aliyun-vod:sync:from-remote --limit=50 # Force update existing videos bin/console aliyun-vod:sync:from-remote --force # Dry run (preview only) bin/console aliyun-vod:sync:from-remote --dry-run
aliyun-vod:sync:to-remote
Synchronize local video data to Alibaba Cloud VOD.
# Sync all videos bin/console aliyun-vod:sync:to-remote # Sync specific video bin/console aliyun-vod:sync:to-remote --video-id=VIDEO_ID # Sync videos with specific status bin/console aliyun-vod:sync:to-remote --status=Normal # Limit sync quantity bin/console aliyun-vod:sync:to-remote --limit=50 # Dry run (preview only) bin/console aliyun-vod:sync:to-remote --dry-run
Transcoding Management
aliyun-vod:sync:transcode-task
Synchronize transcoding task status and progress.
# Sync all processing tasks bin/console aliyun-vod:sync:transcode-task # Sync specific task bin/console aliyun-vod:sync:transcode-task --task-id=TASK_ID # Sync tasks with specific status bin/console aliyun-vod:sync:transcode-task --status=Processing # Limit sync quantity bin/console aliyun-vod:sync:transcode-task --limit=50 # Dry run (preview only) bin/console aliyun-vod:sync:transcode-task --dry-run
Statistics and Reports
aliyun-vod:statistics:generate
Generate playback statistics reports.
# Generate daily report for yesterday bin/console aliyun-vod:statistics:generate # Generate report for specific date bin/console aliyun-vod:statistics:generate --date=2024-01-01 # Generate weekly report bin/console aliyun-vod:statistics:generate --type=weekly # Generate monthly report bin/console aliyun-vod:statistics:generate --type=monthly # Output to JSON format bin/console aliyun-vod:statistics:generate --output=json # Save to file bin/console aliyun-vod:statistics:generate --output=json --file=/path/to/report.json # Output to CSV format bin/console aliyun-vod:statistics:generate --output=csv --file=/path/to/report.csv
Data Cleanup
aliyun-vod:cleanup:play-records
Clean up expired playback records.
# Clean records older than 90 days (default) bin/console aliyun-vod:cleanup:play-records # Clean records older than 30 days bin/console aliyun-vod:cleanup:play-records --days=30 # Force cleanup without confirmation bin/console aliyun-vod:cleanup:play-records --force # Dry run (preview only) bin/console aliyun-vod:cleanup:play-records --dry-run
Usage Examples
Basic Video Upload
use Tourze\AliyunVodBundle\Service\VideoUploadService; class VideoController { public function __construct( private VideoUploadService $videoUploadService ) {} public function upload(Request $request) { $uploadedFile = $request->files->get('video'); $config = $this->getVodConfig(); // Get your VOD configuration $result = $this->videoUploadService->uploadVideo( $uploadedFile, $config, 'My Video Title', 'Video description' ); return $this->json($result); } }
Get Video Play Auth
use Tourze\AliyunVodBundle\Service\PlayAuthService; class VideoController { public function __construct( private PlayAuthService $playAuthService ) {} public function getPlayAuth(string $videoId) { $config = $this->getVodConfig(); $playAuth = $this->playAuthService->getPlayAuth($videoId, $config); return $this->json(['playAuth' => $playAuth]); } }
Advanced Usage
Custom Video Processing
use Tourze\AliyunVodBundle\Service\VideoManageService; use Tourze\AliyunVodBundle\Service\TranscodeService; class AdvancedVideoController { public function __construct( private VideoManageService $videoManageService, private TranscodeService $transcodeService ) {} public function processVideo(string $videoId) { $config = $this->getVodConfig(); // Update video metadata $this->videoManageService->updateVideoInfo( $videoId, $config, 'Updated Title', 'Updated Description', ['tag1', 'tag2'] ); // Start transcoding with custom template $transcodeTask = $this->transcodeService->submitTranscodeJobs( $videoId, $config, 'template_group_id' ); return $this->json($transcodeTask); } }
Video Statistics and Analytics
use Tourze\AliyunVodBundle\Service\StatisticsService; class AnalyticsController { public function __construct( private StatisticsService $statisticsService ) {} public function getVideoAnalytics(string $videoId) { $video = $this->getVideo($videoId); // Get comprehensive video statistics $stats = $this->statisticsService->getVideoPlayStats($video); // Get completion rate $completionRate = $this->statisticsService->getVideoCompletionRate($video); // Get user behavior analysis $userBehavior = $this->statisticsService->getUserPlayBehavior($ipAddress); return $this->json([ 'stats' => $stats, 'completion_rate' => $completionRate, 'user_behavior' => $userBehavior ]); } }
Batch Operations
use Tourze\AliyunVodBundle\Repository\VideoRepository; class BatchVideoController { public function __construct( private VideoRepository $videoRepository, private VideoManageService $videoManageService ) {} public function batchUpdateStatus(array $videoIds, string $status) { $config = $this->getVodConfig(); $results = []; foreach ($videoIds as $videoId) { try { $result = $this->videoManageService->updateVideoStatus( $videoId, $config, $status ); $results[] = ['video_id' => $videoId, 'success' => true]; } catch (\Exception $e) { $results[] = [ 'video_id' => $videoId, 'success' => false, 'error' => $e->getMessage() ]; } } return $this->json($results); } }
Admin Interface
The bundle includes EasyAdmin CRUD controllers for managing:
- Videos: Video library management
- Transcoding Tasks: Monitor transcoding progress
- Playback Records: View playback statistics
- VOD Configurations: Manage Alibaba Cloud credentials
API Endpoints
Video Upload
POST /admin/video-upload- Upload video interfacePOST /admin/video-upload/auth- Get upload authorizationGET /admin/video-upload/progress- Check upload progress
Statistics
GET /admin/statistics- Statistics dashboardGET /admin/statistics/popular- Popular videosGET /admin/statistics/range- Date range statisticsGET /admin/statistics/video-detail/{id}- Video detail statistics
Security
Credential Management
Never commit credentials to your repository. Use environment variables or secure configuration management:
# config/packages/aliyun_vod.yaml parameters: env(ALIYUN_ACCESS_KEY_ID): ~ env(ALIYUN_ACCESS_KEY_SECRET): ~ env(ALIYUN_REGION_ID): 'cn-shanghai'
Access Control
Implement proper access control for video operations:
use Symfony\Component\Security\Http\Attribute\IsGranted; class VideoController { #[IsGranted('ROLE_VIDEO_ADMIN')] public function manageVideos() { /* ... */ } #[IsGranted('ROLE_VIDEO_UPLOAD')] public function uploadVideo() { /* ... */ } #[IsGranted('ROLE_STATISTICS_VIEW')] public function viewStatistics() { /* ... */ } }
Data Protection
- Video Privacy: Ensure appropriate access controls for video content
- User Data: Follow GDPR/privacy regulations when storing playback data
- API Security: Use HTTPS for all API communications
- Input Validation: Validate all user inputs, especially file uploads
Best Practices
- Rotate Access Keys: Regularly rotate your Alibaba Cloud access keys
- Limit Permissions: Use IAM policies to limit VOD service permissions
- Monitor Access: Enable logging and monitoring for video operations
- Secure Storage: Encrypt sensitive configuration data at rest
- Rate Limiting: Implement rate limiting for API endpoints
Requirements
- PHP 8.1 or higher
- Symfony 7.3 or higher
- Doctrine ORM
- Alibaba Cloud VOD SDK
License
This bundle is released under the MIT license.
Contributing
Contributions are welcome! Please submit pull requests or create issues for any improvements.
Support
For support and questions, please create an issue in the repository.