Download the PHP package ivkos/wallhaven without Composer
On this page you can find all versions of the php package ivkos/wallhaven. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ivkos/wallhaven
More information about ivkos/wallhaven
Files in ivkos/wallhaven
Package wallhaven
Short Description Wallhaven API - Search, filter and download wallpapers
License MIT
Homepage https://github.com/ivkos/Wallhaven
Informations about the package wallhaven
Wallhaven API for PHP
Description
A PHP library for Wallhaven that allows you to search for wallpapers and get information about them in convenient OOP syntax. Additionally, this library provides the ability to download individual wallpapers, or batch download many wallpapers asynchronously which considerably reduces download times.
Requirements
- PHP 5.4 or newer
- Composer
Install
Create a composer.json
file in your project root:
Run php composer.phar install
to download the library and its dependencies.
Quick Documentation
Add this line to include Composer packages:
Initialize Wallhaven:
If you have an account on Wallhaven, you can use it to login and access all available wallpapers:
Searching
You can search for wallpapers and filter them using the Wallhaven::filter()
method. It returns a Filter
object that acts as a fluent interface with the following methods:
keywords()
– Search query or #tagname, for example:"landscape"
"#cars"
categories()
– Category, or multiple categories as a bit field. For example:Category::PEOPLE
Category::GENERAL | Category::PEOPLE
Category::ALL
(default) - shorthand forCategory::GENERAL | Category::ANIME | Category::PEOPLE
purity()
– Purity, or multiple purities as a bit field. For example:Purity::SFW
(default)Purity::SFW | Purity::SKETCHY
Purity::ALL
- shorthand forPurity::SFW | Purity::SKETCHY | Purity::NSFW
sorting()
– Sorting. Can be one of the following:Sorting::RELEVANCE
(default)Sorting::RANDOM
Sorting::DATE_ADDED
Sorting::VIEWS
Sorting::FAVORITES
order()
– Order of results. Can be one of the following:Order::DESC
(default)Order::ASC
resolutions()
– Resolutions. Should be an array of strings in the format of WxH, for example:["1920x1080"]
["1280x720", "2560x1440"]
ratios()
– Ratios. Should be an array of strings in the format of WxH, for example:["9x16"]
["16x9", "4x3"]
pages()
– Number of pages to fetch from Wallhaven. A single page typically consists of 24, 32 or 64 wallpapers.getWallpapers()
– Execute the search with the specified filters.
Examples:
Returns a WallpaperList
object containing Wallpaper
objects that match the criteria above.
The WallpaperList
object can be accessed like an array, iterated over using foreach
, and has a WallpaperList::count()
method:
Wallpaper Information
The Wallpaper
object has a number of methods that provide information about the wallpaper:
getId()
getTags()
getPurity()
getResolution()
getSize()
getCategory()
getViews()
getFavorites()
getFeaturedBy()
- not accessible if not logged ingetFeaturedDate()
- not accessible if not logged ingetUploadedBy()
getUploadedDate()
getImageUrl()
getThumbnailUrl()
You can get information about a single wallpaper if you know its ID:
You can also get information about wallpapers from a search result:
Downloading
To download a single wallpaper to a specific directory:
To batch download wallpapers from a search result:
You can also create a WallpaperList
, add specific wallpapers to it, and then batch download them, like so: