PHP code example of aldobarr / qbittorrent-php

1. Go to this page and download the library: Download aldobarr/qbittorrent-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aldobarr / qbittorrent-php example snippets




ldoBarr\QBittorrent;

$host = 'http://hostname';
$port = 1234;
$username = 'admin';
$password = 'pass';
$qbt = new QBittorrent($host, $port, $username, $password);
$response = $qbt->request('app/version');
echo $response->getBody()->getContents();

echo $qbt->application()->version();

$hash = 'torrent-hash';
$torrent = $qbt->torrent($hash);

// Note: `torrents/info` is implemented in the base qbittorrent class instead of the Torrent class
$torrents = $qbt->torrents();
foreach ($torrents as $torrent_data) {
	$torrent = $qbt->torrent($torrent_data->hash);

	// Get torrent files
	print_r($torrent->files());
}

$qbt = new QBittorrent(...);
$qbt->addTorrent(file_paths: [
	'files1.torrent' => '/home/user/files1.torrent',
	'files2.torrent' => '/home/user2/some/path/files2.torrent'
]);