Skip to content

Commit 70ee41e

Browse files
committed
make the repo work on mac os silicon
1 parent db18cac commit 70ee41e

File tree

16 files changed

+112
-470
lines changed

16 files changed

+112
-470
lines changed

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,35 @@
22
![Build Elastic Stack](https://github.com/CodelyTV/elastic-stack-example/workflows/Build%20Elastic%20Stack/badge.svg)
33

44
## How to run the Stack
5-
65
To initialize all the needed services.
76

87
```
98
docker-compose up -d
109
```
1110

12-
## How to run PHP sample app
11+
## How to query the Stack directly
12+
Https and authentication have been disabled for the sake of simplicity.
13+
14+
```
15+
curl --location --request GET 'http://localhost:9200/' \
16+
--header 'Content-Type: application/json' \
17+
--data-raw ''
18+
```
1319

14-
Install needed PHP dependencies
20+
21+
## How to run PHP sample app
22+
No local setup is eneded: the php docker-compose service can be used. Access it and install the needed PHP dependencies
1523

1624
```
17-
cd app && composer install
25+
docker-compose exec php
1826
```
1927

20-
Execute the PHP sample application
28+
inside the docker install the dependencies:
29+
```
30+
composer install
31+
```
2132

33+
Execute the PHP sample application within the docker:
2234
```
23-
php app/php/app.php -a fo1 -b bar
35+
php app.php -a fo1 -b bar
2436
```

app/php/app.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Monolog\Logger;
66
use Elastica\Client;
77
use Monolog\Formatter\JsonFormatter;
8-
use Monolog\Handler\ElasticSearchHandler;
98
use Monolog\Handler\ErrorLogHandler;
109
use Monolog\Handler\RotatingFileHandler;
1110

@@ -19,20 +18,28 @@
1918
$log->pushHandler($stdoutHandler);
2019

2120
// File Handler
22-
$fileHandler = new RotatingFileHandler('../var/logs/app.log', 0, Logger::DEBUG);
21+
$fileHandler = new RotatingFileHandler(__DIR__.'/logs/app.log', 0, \Monolog\Level::Debug);
2322
$formatter = new JsonFormatter();
2423
$fileHandler->setFormatter($formatter);
2524
$log->pushHandler($fileHandler);
2625

2726
// Elasticsearch Handler
2827
$elasticaClient = new Client(
2928
[
30-
'host' => 'localhost',
31-
'port' => 9200
29+
'host' => 'elasticsearch',
30+
'port' => 9200,
31+
'transport' => 'http',
32+
'username' => 'elastic',
33+
'password' => 'password',
34+
'auth' => ["elastic", "password"],
35+
'hosts' => ['elasticsearch:9200'],
3236
]
3337
);
3438

35-
$elasticsearchHandler = new ElasticSearchHandler($elasticaClient);
39+
$elasticsearchHandler = new \Monolog\Handler\ElasticaHandler($elasticaClient, ['index' => 'codelytv', 'type' => 'record']);
40+
41+
// Register Handlers
42+
$log->pushHandler($stdoutHandler);
3643
$log->pushHandler($elasticsearchHandler);
3744

3845
// My Application

app/php/composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{
22
"require": {
3-
"monolog/monolog": "^1.23",
4-
"ruflin/elastica": "^6.0"
3+
"ruflin/elastica": "^8.1",
4+
"monolog/monolog": "^3.9.0"
5+
},
6+
"config": {
7+
"allow-plugins": {
8+
"php-http/discovery": true
9+
}
510
}
611
}

0 commit comments

Comments
 (0)