v3.0.0
[3.0.0] - 2026-01-10
Major release introducing production-ready features including custom exceptions, PSR-3 logging, event system, storage abstraction, rate limiting, and virus scanning.
Added
Exception Hierarchy
UploadException- Base exception class with context supportValidationException- Validation errors with factory methodsStorageException- Storage operation failuresFileNotFoundException- Missing file errorsConfigurationException- Configuration issuesImageException- Image processing errors
PSR-3 Logging
LoggerInterface- PSR-3 compatible logging interfaceLogLevel- Log level constantsFileLogger- File-based logger with rotation supportNullLogger- No-op logger for testingLoggerAwareTrait- Trait for adding logging to any class
Validation System
ValidationResult- Rich validation result objectsValidationError- Individual error representationValidatorInterface- Validator contractValidationChain- Chain multiple validators togetherExtensionValidator- Extension whitelist/blacklist validationMimeTypeValidator- MIME type validation with strict modeSizeValidator- File size validation with category limitsFilenameValidator- Forbidden names, path traversal detectionImageDimensionValidator- Image dimension and aspect ratio validation
Storage Abstraction
StorageInterface- Flysystem-compatible storage interfaceLocalStorage- Local filesystem storage adapterFileInfo- File/directory metadata representationStorageManager- Multi-disk storage management
Rate Limiting
RateLimiterInterface- Rate limiter contractRateLimitResult- Rate limit check result with headersInMemoryRateLimiter- Memory-based rate limiterFileRateLimiter- Persistent file-based rate limiter
Virus Scanning
VirusScannerInterface- Virus scanner contractScanResult- Scan result representationClamAvScanner- ClamAV integration (socket + CLI)NullScanner- No-op scanner for development
Event System
EventInterface- Event contractAbstractEvent- Base event classUploadEvents- Event name constantsFileEvent- File-related eventsValidationEvent- Validation events with resultScanEvent- Virus scan eventsEventDispatcher- Event dispatcher with prioritiesListenerInterface- Event listener contract
New Classes
UploadManager- All-in-one upload manager combining all featuresUploadResult- Comprehensive upload result object
Testing
- PHPUnit test suite with unit tests for all new components
phpunit.xmlconfiguration file
Changed
Upload Class
- Integrated
LoggerAwareTraitfor PSR-3 logging - Added
EventDispatcherintegration for upload lifecycle events - Replaced generic exceptions with custom exception hierarchy
- Added
enableExceptions()method to throw exceptions instead of returning false - Added
validate()method returningValidationResultobject - Added
setEventDispatcher()andgetEventDispatcher()methods - Added
getFile()andgetFileName()accessor methods - All validation methods now log warnings on failure
- Events dispatched for: before/after upload, before/after validation, validation failed, upload failed
composer.json
- Updated PHP requirement to 8.1+
- Added dev dependencies: phpunit, phpstan, phpcs
- Added autoload-dev for tests namespace
- Added scripts: test, test-coverage, phpstan, cs-check, cs-fix
- Added suggested packages: ext-gd, league/flysystem, monolog
Documentation
- Comprehensive README.md with all new features
- Usage examples for all components
- Security best practices guide
Examples
- Updated
production.phpwith multi-file upload support - Demonstrates all new features: validation chain, rate limiting, virus scanning, events, logging
Dependencies
- Requires PHP 8.1 or higher
- Requires
fileinfoextension - Requires
jsonextension - Optional:
gdextension for image processing
Migration Guide
Users upgrading from 2.x should note:
- Update PHP version to 8.1 or higher
- Exceptions are now specific types - update catch blocks
- Consider using
UploadManagerfor new projects - Enable logging with
setLogger()method - Use
enableExceptions(true)for exception-based flow - Use
validate()method for detailed validation results