PHP code example of ohnotnow / laravel-transmission
1. Go to this page and download the library: Download ohnotnow/laravel-transmission 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/ */
use Ohffs\LaravelTransmission\Client;
class Whatever
{
protected $transmission;
public function __construct(Client $transmission)
{
$this->transmission = $transmission;
}
public function index()
{
return $this->transmission->all();
}
public function show($id)
{
return $this->transmission->find($id);
}
}
use Ohffs\LaravelTransmission\Transmission;
// ...
$allTorrents = Transmission::all();
$singleTorrent = Transmission::find(1);
$torrent = $this->transmission->find(1);
echo $torrent->toArray();
/*
'name' => 'Some Exciting File',
'id' => 1,
'doneDate' => 0,
'eta' => 1000,
'haveValid' => 0,
'rateDownload' => 0,
'rateUpload' => 0,
'status' => 2,
'totalSize' => 364514248,
'downloadDir' => '/tmp/torrents',
'percentDone' => 0.3,
*/
// And you can also get those as attributes on the object, eg :
echo $torrent->name;
// 'Some Exciting File'