Skip to content

Commit 12ab052

Browse files
authored
Parallel running (#2)
1 parent 44fdbff commit 12ab052

File tree

15 files changed

+813
-1011
lines changed

15 files changed

+813
-1011
lines changed

.env.example renamed to .env.dist

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ DB_USERNAME=root
1515
DB_PASSWORD=
1616

1717
BROADCAST_DRIVER=log
18-
CACHE_DRIVER=file
18+
CACHE_DRIVER=redis
1919
FILESYSTEM_DRIVER=local
20-
QUEUE_CONNECTION=sync
20+
QUEUE_CONNECTION=redis
21+
QUEUE_DRIVER=redis
22+
REDIS_HOST=redis
23+
2124
SESSION_DRIVER=file
2225
SESSION_LIFETIME=120
2326

24-
MEMCACHED_HOST=127.0.0.1
25-
26-
REDIS_HOST=127.0.0.1
2727
REDIS_PASSWORD=null
2828
REDIS_PORT=6379
2929

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ RUN unzip /usr/bin/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip
1717

1818
RUN mkdir -p /entrypoint.d \
1919
&& cp -R /app/docker/provision/entrypoint.d/* /entrypoint.d/ \
20-
# && cp -R /app/docker/config/supervisor/conf.d/* /opt/docker/etc/supervisor.d/ \
20+
&& cp -R /app/docker/supervisor/* /opt/docker/etc/supervisor.d/ \
2121
&& mkdir -p /opt/docker/etc/php/7.1/conf.d \
2222
&& cp /app/docker/config/php/app.ini /opt/docker/etc/php/7.1/conf.d/app.ini \
2323
&& cp /app/docker/config/nginx/sites-enabled/app1.conf /opt/docker/etc/nginx/vhost.conf \

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Then, run the following commands:
88

99
``` bash
1010
$ git clone https://github.com/abrouter/laravel-example.git
11+
$ cp .env.dist .env
1112
$ composer install
1213
$ docker-compose up -d
1314
```
@@ -21,4 +22,4 @@ Color of the button will changing every time by the following spread:
2122
33% - green
2223

2324
## Ready to use ABRouter on your own project ?
24-
Let's go on [ABRouter](https://abrouter.com) and start.
25+
Let's go on [ABRouter](https://abrouter.com) and start.

app/Http/Controllers/ExampleController.php

+18-4
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,28 @@
44
namespace App\Http\Controllers;
55

66
use Abrouter\Client\Client;
7+
use Abrouter\Client\DTO\EventDTO;
78

89
class ExampleController
910
{
1011
public function __invoke(Client $client)
1112
{
12-
$buttonColor = $client->experiments()->run(uniqid(), 'D1D06000-0000-0000-00005030');
13-
return view('button', [
14-
'color' => $buttonColor->getBranchId(),
15-
]);
13+
try {
14+
$userId = uniqid();
15+
$buttonColor = $client->experiments()->run($userId, 'button_color');
16+
$client->statistics()->sendEvent(new EventDTO(
17+
null,
18+
$userId,
19+
'visited_test_page'
20+
));
21+
22+
return view('button', [
23+
'color' => $buttonColor->getBranchId(),
24+
'parallelRunning' => config('abrouter.parallelRunning.enabled') === true,
25+
]);
26+
} catch (\Exception $e) {
27+
die(var_dump($e->getMessage()));
28+
}
29+
1630
}
1731
}

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "MIT",
77
"require": {
88
"php": "^8.0",
9-
"abrouter/abrouter-laravel-bridge": "^0.11",
9+
"abrouter/laravel-abtest": "0.13.0",
1010
"fruitcake/laravel-cors": "^2.0",
1111
"guzzlehttp/guzzle": "^7.0.1",
1212
"laravel/framework": "^8.54",

0 commit comments

Comments
 (0)