Skip to content

Commit 12a1f55

Browse files
committed
Update documentation
1 parent 1b4ebea commit 12a1f55

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

docs/index.rst

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,22 @@ Installation
1515
Usage
1616
=====
1717

18-
Torrent loading from file
19-
-------------------------
18+
Load existing torrent file
19+
--------------------------
2020

2121
.. code-block:: php
2222
2323
<?php
2424
2525
use SandFox\Torrent\TorrentFile;
2626
27+
// from file
2728
$torrent = TorrentFile::load('debian.torrent');
29+
// from string
30+
$torrent = TorrentFile::loadFromString(file_get_contents('debian.torrent'));
2831
29-
Creating torrent for existing directory or file
30-
-----------------------------------------------
32+
Create torrent file for existing directory or file
33+
--------------------------------------------------
3134

3235
.. code-block:: php
3336
@@ -37,14 +40,18 @@ Creating torrent for existing directory or file
3740
3841
$torrent = TorrentFile::fromPath('/home/user/ISO/Debian');
3942
40-
Saving torrent file
41-
-------------------
43+
Save torrent file
44+
-----------------
4245

4346
.. code-block:: php
4447
4548
<?php
4649
50+
// to file
4751
$torrent->store('debian.torrent');
52+
// to string. for example, for downloading
53+
header('Content-Type: application/x-bittorrent');
54+
echo $torrent->storeToString();
4855
4956
Basic fields manipulation
5057
-------------------------
@@ -59,10 +66,16 @@ Basic fields manipulation
5966
6067
// additional announce urls
6168
$announces = $torrent->getAnnounceList();
69+
// plain ordered list
6270
$torrent->setAnnounceList([
6371
'https://example.net/tracker',
6472
'https://example.org/tracker',
6573
]);
74+
// or with tier grouping
75+
$torrent->setAnnounceList([
76+
['https://example.com/tracker', 'https://example.net/tracker'],
77+
'https://example.org/tracker',
78+
]);
6679
6780
// creation date
6881
$created = $torrent->getCreationDate();

0 commit comments

Comments
 (0)