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.
Publish Migrations
Run php artisan migrate to create the channels and categories tables.
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
]);
Generate M3U8
Use the generateM3u8 command:
php artisan iptv:generate
Outputs to storage/app/public/m3u8/channels.m3u8 (default path).
Channel Management
\FelipeMateus\IPTVChannels\Models\Channel for direct DB operations.
$channels = \FelipeMateus\IPTVChannels\Models\Channel::with('category')->get();
M3U8 Generation
\FelipeMateus\IPTVChannels\Facades\IPTVChannels::generateM3u8();
// app/Console/Kernel.php
$schedule->command('iptv:generate')->hourly();
Category Integration
$sportsChannels = \FelipeMateus\IPTVChannels\Models\Channel::where('category_id', 2)->get();
Custom M3U8 Templates
php artisan vendor:publish --provider="FelipeMateus\IPTVChannels\IPTVProvider" --tag="config"
config/iptv-channels.php to customize the M3U8 structure (e.g., add headers/footers).Route::get('/api/channels', [\FelipeMateus\IPTVChannels\Http\Controllers\ChannelController::class, 'index']);
Route::get('/m3u8/channels.m3u8', function () {
return response()->file(storage_path('app/public/m3u8/channels.m3u8'));
});
use Illuminate\Support\Facades\Validator;
$validator = Validator::make($request->all(), [
'url' => 'required|url|active_url',
'logo' => 'nullable|image|mimes:jpeg,png'
]);
M3U8 Path Configuration
storage/app/public/m3u8/. Ensure the directory exists and is writable:
mkdir -p storage/app/public/m3u8
chmod -R 755 storage/app/public/m3u8
config/iptv-channels.php:
'm3u8_path' => storage_path('custom/m3u8/path'),
URL Validation
http://). Relative paths may break M3U8 parsers.'url' => 'required|url|starts_with:http',
Character Encoding
é, ñ) may cause issues in some players.Concurrency Issues
cache()->lock()) if running scheduled tasks.Log Generation Errors
config/iptv-channels.php:
'debug' => env('IPTV_DEBUG', false),
storage/logs/laravel.log for errors during M3U8 generation.Verify M3U8 Output
storage/app/public/m3u8/channels.m3u8 for malformed entries.Database Constraints
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');
});
Custom Channel Fields
Channel model to add fields (e.g., epg_id, is_favorite):
php artisan make:model ChannelExtension --extend=FelipeMateus\IPTVChannels\Models\Channel
Dynamic M3U8 Filters
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();
});
Multi-Tenant Support
tenant_id column to channels and filter by tenant in the generator:
$channels = \FelipeMateus\IPTVChannels\Models\Channel::where('tenant_id', auth()->id())->get();
Webhook Triggers
use FelipeMateus\IPTVChannels\Events\ChannelUpdated;
event(new ChannelUpdated($channel));
How can I help you explore Laravel packages today?