arokettu/torrent-file
A PHP library for reading, creating, and editing BitTorrent .torrent files. It handles bencoding, v1 and v2 (and hybrid) torrents, and metadata, making it easy to generate or inspect torrents in your PHP applications.
.torrent, prove it's well-formed, extract the file list and total size, compute the v1 infohash, and reject duplicates or malformed uploads before anything touches storage. This package is the format-level layer for that, instead of a bespoke parser..torrent from inside the app rather than shelling out to mktorrent or transmission-create — keeps the flow in-process, testable, and free of daemon dependencies.Adopt when:
bencode_decode() you wrote in an afternoon.Look elsewhere when:
For executives. A small, MIT-licensed PHP library that reads and writes .torrent files. It removes a "we hand-rolled a binary format parser" risk from our upload and distribution flows, and it's the difference between shipping passkey-personalized .torrent downloads in a sprint versus a quarter. Cost is negligible; the alternative is roughly 2–4 engineer-weeks plus perpetual edge-case maintenance and a parser that has to eat hostile uploads on day one. The real risk is bus factor, not capability — mitigated by a permissive license and a codebase small enough to fork. Recommendation: one-day spike, then adopt for metadata only, with hashing offloaded if file sizes are large.
For engineering. Typed, immutable object model over bencode: parse → inspect → modify → serialize round-trip, infohash computation, magnet generation, file and piece metadata, v1 with hybrid v2 where relevant. No extensions, no daemon, no network. Treat uploads as untrusted: cap payload size, cap nesting depth, run inside a worker with memory limits. Pin the version — the maintainer is active but the project is small.
The ask. Approve a spike and add it as a dependency on the upload/download path, with a documented fallback of shelling out to a native torrent tool if hashing throughput becomes the bottleneck.
How can I help you explore Laravel packages today?