Большая переработка

- миграция с Flight на Slim v4
- кэширование ini-файла
- кэширование скачанных плейлистов
- прочее
This commit is contained in:
2025-03-03 13:04:05 +08:00
parent de84bc8ae9
commit 00d612c0e9
29 changed files with 2341 additions and 2094 deletions

View File

@@ -3,17 +3,13 @@
declare(strict_types=1);
return [
// https://flightphp.com/learn#configuration
'flight.base_url' => env('APP_URL', 'http://localhost:8080'),
'flight.case_sensitive' => bool(env('FLIGHT_CASE_SENSITIVE', false)),
'flight.handle_errors' => bool(env('FLIGHT_HANDLE_ERRORS', true)),
'flight.log_errors' => bool(env('FLIGHT_LOG_ERRORS', true)),
'flight.views.path' => views_path(),
'flight.views.extension' => '.twig',
'twig.cache' => bool(env('TWIG_CACHE', true)) ? cache_path() . '/views' : false,
'twig.debug' => bool(env('TWIG_DEBUG', false)),
'app.title' => env('APP_TITLE', 'IPTV Playlists'),
'app.pls_encodings' => [
'base_url' => env('APP_URL', 'http://localhost:8080'),
'debug' => bool(env('APP_DEBUG', false)),
'env' => env('APP_ENV', env('IPTV_ENV', 'prod')),
'title' => env('APP_TITLE', 'IPTV Плейлисты'),
'user_agent' => env('USER_AGENT'),
'page_size' => (int)env('PAGE_SIZE', 10),
'pls_encodings' => [
'UTF-8',
'CP1251',
// 'CP866',

File diff suppressed because it is too large Load Diff

11
src/config/redis.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
return [
'host' => env('REDIS_HOST', 'keydb'),
'port' => (int)env('REDIS_PORT', 6379),
'password' => env('REDIS_PASSWORD'),
'db' => (int)env('REDIS_DB', 0),
'ttl_days' => (int)env('REDIS_TTL_DAYS', 14) * 60 * 60 * 24, // 2 недели
];

View File

@@ -1,17 +1,52 @@
<?php
declare(strict_types=1);
use App\Controllers\HomeController;
use App\Controllers\PlaylistController;
use App\Controllers\ApiController;
use App\Controllers\BasicController;
use App\Controllers\WebController;
return [
'GET /' => [HomeController::class, 'index'],
'GET /page/@page:[0-9]+' => [HomeController::class, 'index'],
'GET /faq' => [HomeController::class, 'faq'],
'GET /logo' => [PlaylistController::class, 'logo'],
'GET /@id:[a-zA-Z0-9_-]+' => [PlaylistController::class, 'download'],
'GET /?[a-zA-Z0-9_-]+' => [PlaylistController::class, 'download'],
'GET /@id:[a-zA-Z0-9_-]+/details' => [PlaylistController::class, 'details'],
'GET /@id:[a-zA-Z0-9_-]+/json' => [PlaylistController::class, 'json'],
[
'method' => 'GET',
'path' => '/[page/{page:[0-9]+}]',
'handler' => [WebController::class, 'home'],
'name' => 'home',
],
[
'method' => 'GET',
'path' => '/faq',
'handler' => [WebController::class, 'faq'],
'name' => 'faq',
],
[
'method' => 'GET',
'path' => '/logo',
'handler' => [WebController::class, 'logo'],
'name' => 'logo',
],
[
'method' => 'GET',
'path' => '/{code:[0-9a-zA-Z]+}',
'handler' => [WebController::class, 'redirect'],
'name' => 'redirect',
],
[
'method' => 'GET',
'path' => '/{code:[0-9a-zA-Z]+}/details',
'handler' => [WebController::class, 'details'],
'name' => 'details',
],
[
'method' => 'GET',
'path' => '/{code:[0-9a-zA-Z]+}/json',
'handler' => [ApiController::class, 'json'],
'name' => 'json',
],
[
'method' => '*',
'path' => '/{path:.*}',
'handler' => [BasicController::class, 'notFound'],
'name' => 'not-found',
],
// ...
];

8
src/config/twig.php Normal file
View File

@@ -0,0 +1,8 @@
<?php
declare(strict_types=1);
return [
'cache' => bool(env('TWIG_USE_CACHE', true)) ? cache_path() . '/views' : false,
'debug' => bool(env('TWIG_DEBUG', false)),
];