Download the PHP package knops/virustotal-client without Composer
On this page you can find all versions of the php package knops/virustotal-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download knops/virustotal-client
More information about knops/virustotal-client
Files in knops/virustotal-client
Package virustotal-client
Short Description A PHP client for the VirusTotal API v3
License MIT
Informations about the package virustotal-client
VirusTotal Client Library
A PHP library for scanning files using the VirusTotal API v3. This library follows PSR standards and provides a clean, type-safe interface for file scanning and analysis.
Features
- ✅ PSR-18 HTTP Client - Uses PSR HTTP standards for maximum compatibility
- ✅ Type Safety - Full PHP 8.1+ type declarations with strict types
- ✅ Comprehensive API - Upload files, check analysis status, and get detailed results
- ✅ Error Handling - Proper exception handling with descriptive messages
- ✅ Async Support - Poll for results or wait for completion
- ✅ Protected ZIP Support - Handle password-protected ZIP files
- ✅ Detailed Results - Access engine-specific results and statistics
- ✅ Factory Pattern - Easy setup with popular HTTP clients
Installation
Install via Composer:
For the easiest setup with Guzzle HTTP client:
Quick Start
Using the Factory (Recommended)
Manual Setup with Custom HTTP Client
Usage Examples
Basic File Scanning
Scanning Password-Protected ZIP Files
Getting Detailed Results
Advanced: Custom Polling
API Reference
VirusTotalClient
Methods
-
scanFile(string $filePath, ?string $password = null): ScanResponse- Upload a file for scanning
- Returns scan response with analysis ID
-
getAnalysis(string $analysisId): AnalysisResponse- Get analysis results by ID
- Returns detailed analysis response
scanFileAndWait(string $filePath, ?string $password = null, int $maxWaitTime = 300, int $pollInterval = 10): AnalysisResponse- Scan file and wait for completion
- Automatically polls for results
ScanResponse
Methods
getAnalysisId(): string- Get the analysis ID for checking resultsgetType(): string- Get the response typegetRawData(): array- Get raw API response data
AnalysisResponse
Status Methods
isCompleted(): bool- Check if analysis is finishedgetStatus(): string- Get current analysis statusisMalicious(): bool- Check if file has malicious detectionsisSuspicious(): bool- Check if file has suspicious detectionsisClean(): bool- Check if file is clean
Statistics Methods
getStats(): array- Get detection statisticsgetMaliciousCount(): int- Number of malicious detectionsgetSuspiciousCount(): int- Number of suspicious detectionsgetTotalEngines(): int- Total number of scanning engines
Results Methods
getEngineResults(): array- Get all engine resultsgetMaliciousResults(): array- Get only malicious detectionsgetSuspiciousResults(): array- Get only suspicious detections
File Information Methods
getFileHash(): ?string- Get SHA256 hashgetFileName(): ?string- Get original filenamegetFileSize(): ?int- Get file size in bytesgetFileType(): ?string- Get file type descriptiongetScanDate(): ?int- Get scan timestamp
Utility Methods
getSummary(): array- Get comprehensive summarygetRawData(): array- Get raw API response data
Error Handling
The library throws VirusTotalException for various error conditions:
Requirements
- PHP 8.1 or higher
- PSR-18 HTTP Client implementation
- PSR-17 HTTP Factory implementation
- VirusTotal API key
Getting a VirusTotal API Key
- Sign up at VirusTotal
- Go to your profile settings
- Copy your API key from the API Key section
Rate Limits
VirusTotal has rate limits based on your account type:
- Public API: 4 requests per minute
- Premium API: Higher limits based on subscription
The library does not automatically handle rate limiting, so you may need to implement delays between requests for high-volume usage.
Testing
Run the test suite:
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
This library is licensed under the MIT License. See the LICENSE file for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Changelog
1.0.0
- Initial release
- File scanning functionality
- Analysis result retrieval
- PSR HTTP client support
- Comprehensive test coverage
All versions of virustotal-client with dependencies
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.0 || ^2.0