Info Fields#

Fields of the info dictionary of the torrent file. The info dictionary is the primary data of the torrent file. Using any setters here will change infoHash and the result will be considered a separate torrent file by the trackers.

Directory or File#

New in version 2.2.

A method to check if a directory or a file is encoded.

<?php
$isDirectory = $torrent->isDirectory();

Info Hash#

Methods to get info hash of the torrent file.

V1#

New in version 2.3/3.1.

Get V1 info hash if V1 metadata is present or null if not.

<?php
$infoHash = $torrent->getInfoHashV1();

V2#

New in version 2.3/3.1.

Get V2 info hash if V2 metadata is present or null if not.

<?php
$infoHash = $torrent->getInfoHashV2();

General method#

Changed in version 2.3/3.1: The method returns V2 info hash if the metadata is present

Get V2 info hash if V2 metadata is present, fall back to V1 info hash.

<?php
$infoHash = $torrent->getInfoHash();

All hashes#

New in version 2.3/3.1.

Get all available hashes as array.

<?php
$infoHashes = $torrent->getInfoHashes();
$infoHashes[1]; // V1 info hash if V1 metadata is present
$infoHashes[2]; // V2 info hash if V2 metadata is present

Name#

A base name of the encoded file or directory.

Warning

Setter will do a minimal check that the name can be a valid file name: it should not be empty and should not contain slashes and zero bytes. It also won’t allow you to unset the name.

However the content of the name field in the parsed file is not guaranteed to exist or be valid.

<?php
// should be a valid file/dir name
$torrent->setName('file.iso');
// stored name may be null or invalid :(
$name = $torrent->getName();

Private#

Note

BEP-27 Private Torrents

Get / set / unset the private flag.

<?php
$isPrivate = $torrent->isPrivate();
$torrent->setPrivate(true);