Torrent File

Packagist GitLab GitHub Bitbucket Gitea

A PHP Class to work with torrent files


composer require sandfoxme/torrent-file


Torrent loading from file


use SandFox\Torrent\TorrentFile;

$torrent = TorrentFile::load('debian.torrent');

Creating torrent for existing directory or file


use SandFox\Torrent\TorrentFile;

$torrent = TorrentFile::fromPath('/home/user/ISO/Debian');

Saving torrent file



Basic fields manipulation


// main announce url
$announce = $torrent->getAnnounce();

// additional announce urls
$announces = $torrent->getAnnounceList();

// creation date
$created = $torrent->getCreationDate();

// comment
$comment = $torrent->getComment();
$torrent->setComment('This is a very cool torrent');

// created by
$createdBy = $torrent->getCreatedBy();

// private marker
$private = $torrent->isPrivate();

Possible future features

  • Files model (chunks and offsets for files)
  • Chunks model (files and their offsets, chunk data validation)
  • Info verification for existing files on disk


The library is available as open source under the terms of the MIT License.