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

Iptv Channels Laravel Package

felipemateus/iptv-channels

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation Run composer require felipemateus/iptv-channels in your Laravel 9.x project root. Add FelipeMateus\IPTVChannels\IPTVProvider::class to config/app.php under providers.

  2. Publish Migrations Run php artisan migrate to create the channels and categories tables.

  3. First Use Case Access the admin panel (if integrated with laravel-iptv-cms) or manually create a channel via Tinker:

    php artisan tinker
    
    $channel = \FelipeMateus\IPTVChannels\Models\Channel::create([
        'name' => 'Test Channel',
        'logo' => 'logo.png',
        'url' => 'http://example.com/stream.m3u8',
        'category_id' => 1 // Assuming a category exists
    ]);
    
  4. Generate M3U8 Use the generateM3u8 command:

    php artisan iptv:generate
    

    Outputs to storage/app/public/m3u8/channels.m3u8 (default path).


Implementation Patterns

Core Workflows

  1. Channel Management

    • CRUD via Eloquent: Use \FelipeMateus\IPTVChannels\Models\Channel for direct DB operations.
      $channels = \FelipeMateus\IPTVChannels\Models\Channel::with('category')->get();
      
    • Bulk Operations: Leverage collections for batch updates (e.g., renaming channels).
  2. M3U8 Generation

    • Manual Trigger: Call the generator via Artisan or a facade (if exposed):
      \FelipeMateus\IPTVChannels\Facades\IPTVChannels::generateM3u8();
      
    • Scheduled Tasks: Use Laravel’s scheduler to auto-generate M3U8:
      // app/Console/Kernel.php
      $schedule->command('iptv:generate')->hourly();
      
  3. Category Integration

    • Group channels by categories (e.g., "Sports", "News") for organized M3U8 output.
    • Example:
      $sportsChannels = \FelipeMateus\IPTVChannels\Models\Channel::where('category_id', 2)->get();
      
  4. Custom M3U8 Templates

    • Override the default M3U8 template by publishing config:
      php artisan vendor:publish --provider="FelipeMateus\IPTVChannels\IPTVProvider" --tag="config"
      
    • Modify config/iptv-channels.php to customize the M3U8 structure (e.g., add headers/footers).

Integration Tips

  • API Endpoints: Expose channels/categories via Laravel routes:
    Route::get('/api/channels', [\FelipeMateus\IPTVChannels\Http\Controllers\ChannelController::class, 'index']);
    
  • Frontend Integration: Serve the M3U8 file via a route:
    Route::get('/m3u8/channels.m3u8', function () {
        return response()->file(storage_path('app/public/m3u8/channels.m3u8'));
    });
    
  • Validation: Use Laravel’s validation rules for channel creation:
    use Illuminate\Support\Facades\Validator;
    $validator = Validator::make($request->all(), [
        'url' => 'required|url|active_url',
        'logo' => 'nullable|image|mimes:jpeg,png'
    ]);
    

Gotchas and Tips

Pitfalls

  1. M3U8 Path Configuration

    • Default path is storage/app/public/m3u8/. Ensure the directory exists and is writable:
      mkdir -p storage/app/public/m3u8
      chmod -R 755 storage/app/public/m3u8
      
    • Customize the path in config/iptv-channels.php:
      'm3u8_path' => storage_path('custom/m3u8/path'),
      
  2. URL Validation

    • The package assumes URLs are absolute (e.g., http://). Relative paths may break M3U8 parsers.
    • Validate URLs strictly:
      'url' => 'required|url|starts_with:http',
      
  3. Character Encoding

    • M3U8 files are UTF-8 by default. Special characters (e.g., é, ñ) may cause issues in some players.
    • Test with a minimal set of channels if encoding fails.
  4. Concurrency Issues

    • Avoid generating M3U8 during high-traffic periods. Use a lock (e.g., Laravel’s cache()->lock()) if running scheduled tasks.

Debugging

  1. Log Generation Errors

    • Enable Laravel logging in config/iptv-channels.php:
      'debug' => env('IPTV_DEBUG', false),
      
    • Check storage/logs/laravel.log for errors during M3U8 generation.
  2. Verify M3U8 Output

    • Manually inspect storage/app/public/m3u8/channels.m3u8 for malformed entries.
    • Use an online M3U8 validator (e.g., m3u8tools.com).
  3. Database Constraints

    • Ensure channels table has a category_id foreign key referencing categories(id):
      Schema::table('channels', function (Blueprint $table) {
          $table->foreign('category_id')->references('id')->on('categories');
      });
      

Extension Points

  1. Custom Channel Fields

    • Extend the Channel model to add fields (e.g., epg_id, is_favorite):
      php artisan make:model ChannelExtension --extend=FelipeMateus\IPTVChannels\Models\Channel
      
    • Update migrations and M3U8 templates accordingly.
  2. Dynamic M3U8 Filters

    • Override the generateM3u8 logic to filter channels dynamically (e.g., by user role):
      // app/Providers/IPTVServiceProvider.php
      $this->app->bind(\FelipeMateus\IPTVChannels\Contracts\M3U8Generator::class, function () {
          return new CustomM3U8Generator();
      });
      
  3. Multi-Tenant Support

    • Add a tenant_id column to channels and filter by tenant in the generator:
      $channels = \FelipeMateus\IPTVChannels\Models\Channel::where('tenant_id', auth()->id())->get();
      
  4. Webhook Triggers

    • Dispatch events after channel updates to trigger external actions (e.g., notify a CDN):
      use FelipeMateus\IPTVChannels\Events\ChannelUpdated;
      event(new ChannelUpdated($channel));
      
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor