Skip to content

Commit 9500ca1

Browse files
committed
Fixed README and params
1 parent 1c71437 commit 9500ca1

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ WORKDIR /app
33
COPY . /app
44
RUN composer install
55
EXPOSE 8000
6-
CMD [ "php", "-S", "0.0.0.0:8000", "-t", "examples" ]
6+
CMD [ "php", "-S", "0.0.0.0:8000", "-t", "controllers" ]

controllers/train_carriages.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
require dirname(__DIR__) . '/vendor/autoload.php';
3+
$config = new Rzd\Config();
4+
$config->setUserAgent('Mozilla 5');
5+
$config->setReferer('https://rzd.ru');
6+
$api = new Rzd\Api($config);
7+
$tomorrow = new DateTime('tomorrow');
8+
$params = [
9+
'code0' => $_GET['code0'],
10+
'code1' => $_GET['code1'],
11+
'tnum0' => $_GET['tnum0'],
12+
'time0' => $_GET['time0'],
13+
'dt0' => $_GET['dt0'] ?? $tomorrow->format('d.m.Y'),
14+
'dir' => $_GET['dir'] ?? 0,
15+
];
16+
header('Content-type: application/json');
17+
echo $api->trainCarriages($params);
18+
?>

controllers/train_routes.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
require dirname(__DIR__) . '/vendor/autoload.php';
3+
$config = new Rzd\Config();
4+
$config->setUserAgent('Mozilla 5');
5+
$config->setReferer('https://rzd.ru');
6+
$api = new Rzd\Api($config);
7+
$tomorrow = new DateTime('tomorrow');
8+
$params = [
9+
'code0' => $_GET['code0'],
10+
'code1' => $_GET['code1'],
11+
'dir' => $_GET['dir'] ?? 0,
12+
'tfl' => $_GET['tfl'] ?? 3,
13+
'checkSeats' => $_GET['checkSeats'] ?? 1,
14+
'dt0' => $_GET['dt0'] ?? $tomorrow->format('d.m.Y'),
15+
'md' => $_GET['md'] ?? 0,
16+
];
17+
header('Content-type: application/json');
18+
echo $api->trainRoutes($params);
19+
?>

readme.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@
1818

1919
### Демонстрация возможностей
2020

21+
#### Быстрый способ (Docker)
22+
23+
```commandline
24+
docker run -p 8000:8000 --rm --name rzd-api -v $(pwd):/app-it pavelsr/rzd-api
25+
curl -s 'http://127.0.0.1:8000/train_routes.php?code0=2004000&code1=2000000'
26+
```
27+
28+
Если вы предпочитаете Github Container Registry вы можете также использовать образ `ghcr.io/pavelsr/rzd-api:latest`
29+
30+
#### Локальная установка
31+
2132
Скачайте архив, распакуйте и перейдите в директорию
2233

2334
Установите необходимые зависимости

0 commit comments

Comments
 (0)