Download the PHP package resoul/imdb without Composer
On this page you can find all versions of the php package resoul/imdb. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package imdb
IMDB parser
Box Office Mojo parser for demo purpose only.
Table of Contents
- Overview
- Installation
- Quick Start
- API Reference
- Models
- Examples
- Error Handling
- Performance Considerations
- Contributing
Overview
The IMDB Parser is a PHP library that scrapes Box Office Mojo and IMDB Pro to extract movie and box office data. It provides a clean, object-oriented interface for retrieving weekend box office rankings, yearly box office data, and detailed film information.
Features
- Parse weekend box office rankings
- Extract yearly box office data
- Retrieve detailed film information from IMDB Pro
- Built-in caching system
- Comprehensive data models
- Support for cast, crew, and financial data
Requirements
- PHP 8.0 or higher
- ext-dom extension
- ext-libxml extension
- Guzzle HTTP client
Installation
Install via Composer:
Quick Start
API Reference
Parser Class
The main Parser class is the entry point for all parsing operations.
Constructor
Creates a new Parser instance with default HTTP client configuration.
Example:
Methods
setCacheFolder(string $path): static
Sets the cache directory for storing downloaded HTML content.
Parameters:
$path(string): Absolute path to cache directory
Returns: static - For method chaining
Throws: Exception - If directory cannot be created
Example:
byWeekend(string $weekend): static
Configures parser to extract weekend box office data.
Parameters:
$weekend(string): Weekend identifier in format "YYYYWNN" (e.g., "2024W48")
Returns: static - For method chaining
Example:
byYear(string $year): static
Configures parser to extract yearly box office data.
Parameters:
$year(string): Year in YYYY format (e.g., "2024")
Returns: static - For method chaining
Example:
bySource(string $source): static
Configures parser to extract data from a custom URL.
Parameters:
$source(string): Full URL to parse
Returns: static - For method chaining
Example:
run(): IMDB
Executes the parsing operation and returns structured data.
Returns: IMDB - Parsed box office data with releases
Throws: Exception - If parsing fails or network error occurs
Example:
parseTitle(): Film
Parses a single film from IMDB Pro (requires setting source first).
Returns: Film - Detailed film information
Throws: Exception - If parsing fails
Example:
Models
IMDB
Main container for parsed box office data.
Properties
title(string): Descriptive title (e.g., "Weekend Box Office")release(Release[]): Array of release data
Methods
Release
Represents a single film's box office performance.
Properties
rank(int): Box office ranking positionlastWeek(int): Previous week's ranking (0 if new)release(string): Film titleuri(string): Box Office Mojo URLgross(int): Weekend/period gross revenue in dollarstheaters(int): Number of theaters (weekend data only)total(int): Total gross revenue in dollarsweeks(int): Number of weeks in releasefilm(Film): Detailed film information (populated after run())
Methods
Film
Comprehensive film information from IMDB Pro.
Properties
uid(string): IMDB Pro URLreleaseUid(string): Box Office Mojo URLoriginal(string): Original film titleposter(string): Poster image URLdescription(string): Plot summaryreleaseDate(string): Release date (Y-m-d format)certificate(string): MPAA ratingduration(string): Runtime in minutesgenres(GenreEnum[]): Array of genre enumstype(FilmTypeEnum): Movie or TV seriesopening(int|null): Opening weekend grossopeningTheaters(int|null): Opening weekend theater countwideRelease(int|null): Widest theater releasebudget(int|null): Production budgetgross(Gross|null): Worldwide gross breakdowncast(Actor[]|null): Cast and crew informationdistributor(DistributorEnum|null): Distribution company
Methods
Gross
Box office revenue breakdown by market.
Properties
domestic(int|null): US/Canada gross revenueinternational(int|null): International gross revenueworldwide(int|null): Worldwide total gross revenue
Methods
Actor
Cast and crew member information.
Properties
original(string): Person's nameuri(string): IMDB Pro URLrole(RoleEnum): Role type (Actor, Director, etc.)roleName(string|null): Character name (for actors)poster(string|null): Profile image URL
Methods
Enums
FilmTypeEnum
MOVIE(1): Feature filmSERIAL(2): TV series or miniseries
GenreEnum
Available genres: Action, Drama, Comedy, Thriller, etc.
RoleEnum
Available roles: Actor, Director, Writer, Producer, etc.
DistributorEnum
Major film distributors: Warner Bros., Universal Pictures, etc.
Examples
Weekend Box Office Analysis
Yearly Box Office Top 10
Detailed Film Information
Advanced Usage with Error Handling
Error Handling
The parser throws Exception objects for various error conditions:
Common Exceptions
- Network Errors: Connection timeout, DNS resolution failures
- Parsing Errors: Invalid HTML structure, missing elements
- Cache Errors: Unable to create cache directory, permission issues
- Data Validation: Invalid weekend format, missing required data
Best Practices
Performance Considerations
Caching
The parser includes a built-in caching system that stores downloaded HTML files to avoid repeated requests:
Memory Usage
For large datasets (yearly data), consider processing releases in batches:
Rate Limiting
Be respectful of the target websites:
- The parser automatically caches requests to avoid redundant calls
- Consider adding delays between runs if processing multiple time periods
- Monitor your request frequency to avoid being blocked
This comprehensive documentation should help users understand and effectively use the IMDB parser library.