Skip to content

Commit

Permalink
hw13
Browse files Browse the repository at this point in the history
  • Loading branch information
asistent0 committed Feb 2, 2025
1 parent 6b6ca8b commit a0b63f3
Show file tree
Hide file tree
Showing 17 changed files with 86,103 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
APP_ENV=dev
ELASTICSEARCH_HOST=localhost:9200
ELASTICSEARCH_USER=elastic
ELASTICSEARCH_PASSWORD=password
ELASTICSEARCH_CA_BUNDLE=path/to/http_ca.crt
ELASTIC_INDEX=otus-books
INDEX_FILE_PATH=files/books.json
PAGE_SIZE=100
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
.DS_Store
.AppleDouble
.LSOverride
.env
/config/http_ca.crt
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM php:8.2-cli

RUN apt-get update && apt-get install -y \
libzip-dev \
unzip \
&& docker-php-ext-install zip

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

ARG SOURCE_PATH=/var/www/html
WORKDIR $SOURCE_PATH
COPY . $SOURCE_PATH
RUN composer install --no-dev --optimize-autoloader

CMD ["php", "-S", "0.0.0.0:8000"]
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
# PHP_2024
# OTUS BOOK SHOP

https://otus.ru/lessons/razrabotchik-php/?utm_source=github&utm_medium=free&utm_campaign=otus
```shell
docker exec -ti book_shop chmod +x app
```

# Для получения данных с сайта используется команда.

```shell
docker exec -ti book_shop php app app:spider
```

Более подробная информация

```shell
docker exec -ti book_shop php app app:spider --help
```

# Для индексирования данных в эластик команда.

```shell
docker exec -ti book_shop php app app:bulk
```

Более подробная информация

```shell
docker exec -ti book_shop php app app:bulk --help
```

# Для поиска используется команда.

```shell
docker exec -ti book_shop php app app:search
```

Команда поддерживает опции:

```shell
--title="Поиск по названию" # Поиск по части названия
--price=">100" --price="<=200" # Указание фильтра по ценам
--is_comment # Выводит книги только с комментариями
--page=1 # Для постраничного вывода. На одной странице выводится 100.
```

Более подробная информация

```shell
docker exec -ti book_shop php app app:search --help
```

# Для более подробной информации по проекту.

```shell
docker exec -ti book_shop php app --help
```
10 changes: 10 additions & 0 deletions app
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env php

<?php

require __DIR__.'/vendor/autoload.php';

use KRudenko\Otus\Core\Kernel;

$kernel = new Kernel();
$kernel->handleCommand($argv);
27 changes: 27 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "krudenko/hw13",
"description": "Otus Home Work 13",
"type": "project",
"autoload": {
"psr-4": {
"KRudenko\\Otus\\": "src/"
}
},
"require": {
"php": "^8.2",
"elasticsearch/elasticsearch": "^8.17",
"vlucas/phpdotenv": "^5.6",
"php-di/php-di": "^7.0",
"symfony/console": "^7.2",
"symfony/finder": "^7.2",
"symfony/browser-kit": "^7.2",
"symfony/http-client": "^7.2",
"symfony/dom-crawler": "^7.2",
"symfony/css-selector": "^7.2"
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
Loading

0 comments on commit a0b63f3

Please sign in to comment.