wip redis
This commit is contained in:
@@ -1,7 +1,15 @@
|
|||||||
APP_TITLE='Плейлисты IPTV'
|
APP_TITLE='Плейлисты IPTV'
|
||||||
APP_URL=http://localhost:8080
|
APP_URL=http://localhost:${IPTV_NGNIX_PORT}
|
||||||
|
|
||||||
TWIG_CACHE=1
|
TWIG_CACHE=1
|
||||||
TWIG_DEBUG=0
|
TWIG_DEBUG=0
|
||||||
|
|
||||||
FLIGHT_CASE_SENSITIVE=0
|
FLIGHT_CASE_SENSITIVE=0
|
||||||
FLIGHT_HANDLE_ERRORS=1
|
FLIGHT_HANDLE_ERRORS=1
|
||||||
FLIGHT_LOG_ERRORS=1
|
FLIGHT_LOG_ERRORS=1
|
||||||
|
|
||||||
|
REDIS_HOST=iptv-keydb
|
||||||
|
REDIS_PORT=6379
|
||||||
|
REDIS_DB=0
|
||||||
|
REDIS_USER=
|
||||||
|
REDIS_PASS=
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"ext-fileinfo": "*",
|
"ext-fileinfo": "*",
|
||||||
|
"ext-redis": "*",
|
||||||
"mikecao/flight": "^3.12",
|
"mikecao/flight": "^3.12",
|
||||||
"symfony/dotenv": "^7.1",
|
"symfony/dotenv": "^7.1",
|
||||||
"twig/twig": "^3.14"
|
"twig/twig": "^3.14"
|
||||||
|
|||||||
31
src/svc-main/composer.lock
generated
31
src/svc-main/composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "1aaea4609092e8a88074f050dab42323",
|
"content-hash": "4d763eef27bbfd40014e392726e5afc1",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "mikecao/flight",
|
"name": "mikecao/flight",
|
||||||
@@ -244,8 +244,8 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"thanks": {
|
"thanks": {
|
||||||
"name": "symfony/polyfill",
|
"url": "https://github.com/symfony/polyfill",
|
||||||
"url": "https://github.com/symfony/polyfill"
|
"name": "symfony/polyfill"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -323,8 +323,8 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"thanks": {
|
"thanks": {
|
||||||
"name": "symfony/polyfill",
|
"url": "https://github.com/symfony/polyfill",
|
||||||
"url": "https://github.com/symfony/polyfill"
|
"name": "symfony/polyfill"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -397,8 +397,8 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"thanks": {
|
"thanks": {
|
||||||
"name": "symfony/polyfill",
|
"url": "https://github.com/symfony/polyfill",
|
||||||
"url": "https://github.com/symfony/polyfill"
|
"name": "symfony/polyfill"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -455,16 +455,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "twig/twig",
|
"name": "twig/twig",
|
||||||
"version": "v3.16.0",
|
"version": "v3.17.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/twigphp/Twig.git",
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
"reference": "475ad2dc97d65d8631393e721e7e44fb544f0561"
|
"reference": "677ef8da6497a03048192aeeb5aa3018e379ac71"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/475ad2dc97d65d8631393e721e7e44fb544f0561",
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/677ef8da6497a03048192aeeb5aa3018e379ac71",
|
||||||
"reference": "475ad2dc97d65d8631393e721e7e44fb544f0561",
|
"reference": "677ef8da6497a03048192aeeb5aa3018e379ac71",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -519,7 +519,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/twigphp/Twig/issues",
|
"issues": "https://github.com/twigphp/Twig/issues",
|
||||||
"source": "https://github.com/twigphp/Twig/tree/v3.16.0"
|
"source": "https://github.com/twigphp/Twig/tree/v3.17.1"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -531,7 +531,7 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-11-29T08:27:05+00:00"
|
"time": "2024-12-12T09:58:10+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
@@ -541,10 +541,11 @@
|
|||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "^8.2",
|
"php": "^8.4",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"ext-fileinfo": "*"
|
"ext-fileinfo": "*",
|
||||||
|
"ext-redis": "*"
|
||||||
},
|
},
|
||||||
"platform-dev": {},
|
"platform-dev": {},
|
||||||
"plugin-api-version": "2.6.0"
|
"plugin-api-version": "2.6.0"
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
// https://flightphp.com/learn#configuration
|
// https://flightphp.com/learn#configuration
|
||||||
'flight.base_url' => env('APP_URL', 'http://localhost:8080'),
|
'flight.base_url' => env('APP_URL', 'http://localhost:' . env('IPTV_NGNIX_PORT')),
|
||||||
'flight.case_sensitive' => bool(env('FLIGHT_CASE_SENSITIVE', false)),
|
'flight.case_sensitive' => bool(env('FLIGHT_CASE_SENSITIVE', false)),
|
||||||
'flight.handle_errors' => bool(env('FLIGHT_HANDLE_ERRORS', true)),
|
'flight.handle_errors' => bool(env('FLIGHT_HANDLE_ERRORS', true)),
|
||||||
'flight.log_errors' => bool(env('FLIGHT_LOG_ERRORS', true)),
|
'flight.log_errors' => bool(env('FLIGHT_LOG_ERRORS', true)),
|
||||||
'flight.views.path' => views_path(),
|
'flight.views.path' => views_path(),
|
||||||
'flight.views.extension' => '.twig',
|
'flight.views.extension' => '.twig',
|
||||||
|
|
||||||
'twig.cache' => bool(env('TWIG_CACHE', true)) ? cache_path() . '/views' : false,
|
'twig.cache' => bool(env('TWIG_CACHE', true)) ? cache_path() . '/views' : false,
|
||||||
'twig.debug' => bool(env('TWIG_DEBUG', false)),
|
'twig.debug' => bool(env('TWIG_DEBUG', false)),
|
||||||
|
|
||||||
'app.title' => env('APP_TITLE', 'IPTV Playlists'),
|
'app.title' => env('APP_TITLE', 'IPTV Playlists'),
|
||||||
'app.pls_encodings' => [
|
'app.pls_encodings' => [
|
||||||
'UTF-8',
|
'UTF-8',
|
||||||
@@ -19,4 +21,10 @@ return [
|
|||||||
// 'CP866',
|
// 'CP866',
|
||||||
// 'ISO-8859-5',
|
// 'ISO-8859-5',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'redis.host' => env('REDIS_HOST', 'iptv-keydb'),
|
||||||
|
'redis.port' => (int)env('REDIS_PORT', 6379),
|
||||||
|
// 'redis.user' => env('REDIS_USER'),
|
||||||
|
// 'redis.password' => env('REDIS_PASS'),
|
||||||
|
'redis.database' => (int)env('REDIS_DB', 0),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ class HomeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(int $page = 1): void
|
public function index(int $page = 1): void
|
||||||
{
|
{
|
||||||
|
$redis = Flight::get('redis');
|
||||||
|
|
||||||
// если пришёл любой get-параметр, то считаем его как id плейлиста и перебрасываем на страницу о нём
|
// если пришёл любой get-параметр, то считаем его как id плейлиста и перебрасываем на страницу о нём
|
||||||
if (Flight::request()->query->count() > 0) {
|
if (Flight::request()->query->count() > 0) {
|
||||||
$id = Flight::request()->query->keys()[0];
|
$id = Flight::request()->query->keys()[0];
|
||||||
|
|||||||
@@ -71,4 +71,21 @@ final class Bootstrapper
|
|||||||
Flight::route($route, $handler);
|
Flight::route($route, $handler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function bootRedis(): void
|
||||||
|
{
|
||||||
|
$options = [
|
||||||
|
'host' => config('redis.host'),
|
||||||
|
'port' => config('redis.port'),
|
||||||
|
// 'username' => config('redis.user'),
|
||||||
|
// 'pass' => config('redis.password'),
|
||||||
|
'connectTimeout' => 1,
|
||||||
|
];
|
||||||
|
|
||||||
|
$redis = new \Redis($options);
|
||||||
|
$redis->select((int)config('redis.database'));
|
||||||
|
$redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_JSON);
|
||||||
|
|
||||||
|
Flight::set('redis', $redis);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,5 @@ Bootstrapper::bootSettings();
|
|||||||
Bootstrapper::bootTwig();
|
Bootstrapper::bootTwig();
|
||||||
Bootstrapper::bootCore();
|
Bootstrapper::bootCore();
|
||||||
Bootstrapper::bootRoutes();
|
Bootstrapper::bootRoutes();
|
||||||
|
Bootstrapper::bootRedis();
|
||||||
Flight::start();
|
Flight::start();
|
||||||
|
|||||||
Reference in New Issue
Block a user