zloadmin / laravel-transmission-php
本包的最新版本(dev-master)没有提供许可证信息。
Laravel PHP Transmission 客户端门面
dev-master
2022-04-13 14:19 UTC
Requires
- php: >=7.0.0
- ext-curl: *
- transmission-php/transmission-php: *
This package is auto-updated.
Last update: 2024-09-13 19:09:27 UTC
README
composer require zloadmin/laravel-transmission-php:dev-master
设置配置
发布配置文件
php artisan vendor:publish --provider="TransmissionPHP\Providers\TransmissionProvider"
在您的 .env 文件中添加您的参数
TRANSMISSION_HOST=localhost
TRANSMISSION_PORT=9091
TRANSMISSION_PATH=/transmission/rpc
如果使用认证,请添加用户名和密码
TRANSMISSION_USERNAME=username
TRANSMISSION_PASSWORD=password
使用
<?php use TransmissionPHP\Facades\Transmission; $all_torrents = Transmission::all();
使用其他方法
此包仅是原始 API 客户端(https://github.com/transmission-php/transmission-php)的 Laravel 门面,您可以使用任何公共方法作为静态方法。
<?php use TransmissionPHP\Facades\Transmission; // Getting all the torrents currently in the download queue $torrents = Transmission::all(); // Getting a specific torrent from the download queue $torrent = Transmission::get(1); // (you can also get a torrent by the hash of the torrent) $torrent = Transmission::get(/* torrent hash */); // Adding a torrent to the download queue $torrent = Transmission::add(/* path to torrent */); // Removing a torrent from the download queue $torrent = Transmission::get(1); Transmission::remove($torrent); // Or if you want to delete all local data too Transmission::remove($torrent, true); // You can also get the Trackers that the torrent currently uses // These are instances of the Transmission\Model\Tracker class $trackers = $torrent->getTrackers(); // You can also get the Trackers statistics and info that the torrent currently has // These are instances of the Transmission\Model\trackerStats class $trackerStats = $torrent->getTrackerStats(); // To get the start date/time of the torrent in UNIX Timestamp format $startTime = $torrent->getStartDate(); // To get the number of peers connected $connectedPeers = $torrent->getPeersConnected(); // Getting the files downloaded by the torrent are available too // These are instances of Transmission\Model\File $files = $torrent->getFiles(); // You can start, stop, verify the torrent and ask the tracker for // more peers to connect to Transmission::stop($torrent); Transmission::start($torrent); Transmission::start($torrent, true); // Pass true if you want to start the torrent immediatly Transmission::verify($torrent); Transmission::reannounce($torrent);