Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Transmission Bundle Laravel Package

chellem/transmission-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require chellem/transmission-bundle:dev-master
    

    Register the bundle in app/AppKernel.php:

    new Transmission\Bundle\TransmissionBundle\TransmissionBundle(),
    
  2. Basic Configuration (config/packages/transmission.yaml):

    transmission:
        host: localhost
        port: 9091
        username: your_username
        password: your_password
    
  3. First Use Case: Inject the TransmissionClient service into a controller or command:

    use Transmission\Bundle\TransmissionBundle\Client\TransmissionClient;
    
    public function __construct(TransmissionClient $transmissionClient) {
        $this->client = $transmissionClient;
    }
    

    Use it to list torrents:

    $torrents = $this->client->getTorrents();
    

Implementation Patterns

Common Workflows

  1. Torrent Management:

    • Add a Torrent:
      $this->client->addTorrent('http://example.com/torrent.torrent');
      
    • Start/Stop Torrents:
      $this->client->startTorrent($torrentId);
      $this->client->stopTorrent($torrentId);
      
  2. File Operations:

    • Verify Integrity:
      $this->client->verifyTorrent($torrentId);
      
    • Recheck Files:
      $this->client->recheckTorrent($torrentId);
      
  3. Monitoring:

    • Get Torrent Stats:
      $stats = $this->client->getTorrentStats($torrentId);
      
    • Get Session Stats:
      $sessionStats = $this->client->getSessionStats();
      

Integration Tips

  • Event Listeners: Extend functionality by listening to transmission events (e.g., torrent completion).

    // src/EventListener/TransmissionListener.php
    public function onTorrentComplete(TorrentEvent $event) {
        // Handle completion logic
    }
    

    Register in services.yaml:

    services:
        App\EventListener\TransmissionListener:
            tags:
                - { name: kernel.event_listener, event: transmission.torrent.complete, method: onTorrentComplete }
    
  • Commands: Create custom Artisan commands for CLI interactions:

    namespace App\Console\Commands;
    
    use Illuminate\Console\Command;
    use Transmission\Bundle\TransmissionBundle\Client\TransmissionClient;
    
    class AddTorrentCommand extends Command {
        protected $transmissionClient;
    
        public function __construct(TransmissionClient $client) {
            $this->transmissionClient = $client;
        }
    
        public function handle() {
            $url = $this->ask('Enter torrent URL');
            $this->transmissionClient->addTorrent($url);
        }
    }
    

Gotchas and Tips

Pitfalls

  1. Authentication:

    • If username/password are null, the bundle defaults to RPC authentication. Ensure your Transmission daemon is configured to allow RPC access without credentials or provide valid credentials to avoid connection errors.
  2. Port Conflicts:

    • Verify the port in config.yml matches your Transmission daemon’s RPC port (default: 9091). Mismatches will result in connection failures.
  3. Deprecated Methods:

    • Some methods may not be documented in the README. Refer to the Transmission RPC API for unsupported operations.
  4. Error Handling:

    • Wrap client calls in try-catch blocks to handle exceptions (e.g., TransmissionException):
      try {
          $this->client->addTorrent($url);
      } catch (\Exception $e) {
          $this->logger->error('Transmission error: ' . $e->getMessage());
      }
      

Debugging

  • Enable RPC Logging: Add this to your Transmission daemon’s settings.json to debug RPC issues:

    "rpc-authentication-required": false,
    "rpc-bind-address": "0.0.0.0",
    "rpc-enabled": true,
    "rpc-port": 9091,
    "rpc-url": "/transmission/rpc",
    "rpc-whitelist": "127.0.0.1",
    "rpc-whitelist-enabled": false
    

    Restart the daemon after changes.

  • Check Connection: Use curl to test RPC connectivity:

    curl --data-binary '{"method":"session-get","arguments":{}}' http://localhost:9091/transmission/rpc
    

Extension Points

  1. Custom Responses: Override the TransmissionClient to extend responses (e.g., add metadata to torrent objects):

    class CustomTransmissionClient extends TransmissionClient {
        public function getTorrents() {
            $torrents = parent::getTorrents();
            foreach ($torrents as $torrent) {
                $torrent->customField = 'value';
            }
            return $torrents;
        }
    }
    

    Register the custom service in services.yaml:

    services:
        Transmission\Bundle\TransmissionBundle\Client\TransmissionClient:
            class: App\Service\CustomTransmissionClient
    
  2. Event Dispatching: Extend the bundle’s event system to trigger custom logic (e.g., notifications):

    // Dispatch a custom event after a torrent completes
    $dispatcher->dispatch(new TorrentCompletedEvent($torrentId));
    
  3. Configuration Overrides: Use environment variables for dynamic configuration (e.g., .env):

    # config/packages/transmission.yaml
    transmission:
        host: '%env(TRANSMISSION_HOST)%'
        port: '%env(int:TRANSMISSION_PORT)%'
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui