Skip to content

Commit 24bece7

Browse files
Moved to hyperf
1 parent ea5164d commit 24bece7

File tree

161 files changed

+9593
-9351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+9593
-9351
lines changed

.env.example

Lines changed: 30 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,53 @@
11
# ENVIRONMENT
22
APP_ENV=dev
3-
DEBUG=true
3+
APP_NAME=collider
4+
APP_DEBUG=true
45
TIMEZONE=Europe/Moscow
56

6-
# APPLICATION
7-
APP_NAME=analytics
8-
APP_VERSION=1.0.0
9-
APP_KEY=base64:your-32-character-secret-key-here
10-
APP_URL=http://localhost
11-
APP_DOMAIN=async-app.local
12-
13-
# SWOOLE SERVER
14-
SWOOLE_HOST=0.0.0.0
15-
SWOOLE_PORT=9501
16-
SWOOLE_WORKER_NUM=auto
17-
SWOOLE_TASK_WORKER_NUM=4
18-
SWOOLE_MAX_REQUEST=10000
19-
SWOOLE_ENABLE_COROUTINE=true
20-
SWOOLE_ENABLE_STATIC_HANDLER=true
21-
SWOOLE_DOCUMENT_ROOT=/app/public
7+
# SCAN
8+
SCAN_CACHEABLE=false
229

2310
# DATABASE
24-
DB_CONNECTION=pgsql
11+
DB_CONNECTION=default
12+
DB_DRIVER=pgsql
2513
DB_HOST=database
2614
DB_PORT=5432
2715
DB_PORTS=5432:5432
28-
DB_DATABASE=app_db
29-
DB_USERNAME=app_user
30-
DB_PASSWORD=secret
16+
DB_DATABASE=collider_db
17+
DB_USERNAME=collider_user
18+
DB_PASSWORD=collider_secret
3119
DB_CHARSET=utf8
3220
DB_COLLATION=utf8_unicode_ci
3321
DB_PREFIX=
34-
DB_POOL_MIN_CONNECTIONS=1
35-
DB_POOL_MAX_CONNECTIONS=10
36-
37-
# POSTGRES CONFIG
38-
PG_MAX_CONNECTIONS=200
39-
PG_SHARED_BUFFERS=256MB
40-
PG_EFFECTIVE_CACHE_SIZE=1GB
41-
PG_MAINTENANCE_WORK_MEM=64MB
42-
PG_CHECKPOINT_COMPLETION_TARGET=0.9
43-
PG_WAL_BUFFERS=16MB
44-
PG_DEFAULT_STATISTICS_TARGET=100
45-
PG_RANDOM_PAGE_COST=1.1
46-
PG_EFFECTIVE_IO_CONCURRENCY=200
47-
PG_WORK_MEM=4MB
48-
PG_MIN_WAL_SIZE=1GB
49-
PG_MAX_WAL_SIZE=4GB
22+
DB_POOL_MIN_CONNECTIONS=10
23+
DB_POOL_MAX_CONNECTIONS=1000
24+
DB_POOL_CONNECT_TIMEOUT=10.0
25+
DB_POOL_WAIT_TIMEOUT=3.0
26+
DB_POOL_HEARTBEAT=60
27+
DB_POOL_MAX_IDLE_TIME=60
5028

5129
# REDIS
5230
REDIS_HOST=redis
31+
REDIS_AUTH=
5332
REDIS_PORT=6379
54-
REDIS_PASSWORD=
55-
REDIS_DATABASE=0
56-
REDIS_PREFIX=
57-
REDIS_POOL_MIN_CONNECTIONS=1
58-
REDIS_POOL_MAX_CONNECTIONS=10
33+
REDIS_DB=0
34+
REDIS_POOL_MIN_CONNECTIONS=10
35+
REDIS_POOL_MAX_CONNECTIONS=1000
36+
REDIS_POOL_CONNECT_TIMEOUT=10.0
37+
REDIS_POOL_WAIT_TIMEOUT=3.0
38+
REDIS_POOL_HEARTBEAT=60
39+
REDIS_POOL_MAX_IDLE_TIME=60
5940

6041
# CACHE
6142
CACHE_DRIVER=redis
62-
CACHE_PREFIX=cache:
63-
CACHE_TTL=3600
64-
65-
# LOGGING
66-
LOG_CHANNEL=stack
67-
LOG_LEVEL=debug
68-
LOG_PATH=/app/var/log
69-
LOG_MAX_FILES=30
70-
TELEMETRY_ENABLED=false
71-
TELEMETRY_DRIVER=null
72-
73-
# SECURITY
74-
CORS_ALLOWED_ORIGINS=*
75-
CORS_ALLOWED_METHODS=GET,POST,PUT,DELETE,OPTIONS
76-
CORS_ALLOWED_HEADERS=Content-Type,Authorization,X-Requested-With
77-
CORS_EXPOSED_HEADERS=
78-
CORS_MAX_AGE=86400
79-
CORS_SUPPORTS_CREDENTIALS=false
43+
CACHE_PREFIX=
44+
CACHE_DEFAULT_TTL=3600
8045

81-
# FILE STORAGE
82-
FILESYSTEM_DRIVER=local
83-
FILESYSTEM_ROOT=/app/var/storage
46+
# LOGGER
47+
LOG_LEVEL=info
48+
LOG_APP=default
49+
LOG_TYPE=single
8450

85-
# Ports
51+
# Nginx
8652
NGINX_PORT_HTTP=80
8753
NGINX_PORT_HTTPS=443

.github/workflows/action.yml

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,28 @@ jobs:
1818
php-version: '8.3'
1919

2020
- name: Install Dependencies
21-
run: composer install --no-interaction --prefer-dist --ignore-platform-reqs
21+
run: composer install --no-interaction --ignore-platform-reqs
2222

2323
- name: Run PHP CS Fixer
2424
run: vendor/bin/php-cs-fixer fix --dry-run
2525

26-
build:
26+
phpstan-check:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- uses: actions/checkout@v4
3030

31-
- name: Verify tools
32-
run: |
33-
make --version
34-
docker --version
35-
docker compose version
36-
37-
- name: Copy environment file
38-
run: cp .env.example .env
39-
40-
- name: Create var directories
41-
run: make var
42-
43-
- name: Install Composer dependencies
44-
run: make composer
45-
46-
- name: Build and start services
47-
run: make start
31+
- name: Setup PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: '8.3'
4835

49-
- name: Wait for services to be ready
50-
run: |
51-
echo "Waiting for services to start..."
52-
sleep 5
53-
docker compose ps
36+
- name: Install Dependencies
37+
run: composer install --no-interaction --ignore-platform-reqs
5438

55-
- name: Cleanup
56-
if: always()
57-
run: make down
39+
- name: Run PHP CS Fixer
40+
run: vendor/bin/phpstan analyse
5841

59-
test:
42+
build-test:
6043
runs-on: ubuntu-latest
6144
steps:
6245
- uses: actions/checkout@v4
@@ -65,7 +48,7 @@ jobs:
6548
run: cp .env.example .env
6649

6750
- name: Create var directories
68-
run: make var
51+
run: make runtime
6952

7053
- name: Install Composer dependencies
7154
run: make composer
@@ -80,7 +63,7 @@ jobs:
8063
docker compose ps
8164
8265
- name: Run migrations
83-
run: docker compose exec -T php php bin/app.php migrate --force
66+
run: docker compose exec -T app bin/hyperf.php migrate
8467

8568
- name: Install curl and jq
8669
run: sudo apt-get update && sudo apt-get install -y curl jq
@@ -89,29 +72,18 @@ jobs:
8972
run: |
9073
echo "Testing API endpoints..."
9174
92-
# Test health endpoint
9375
curl -f http://localhost/health && echo "✓ Health endpoint works"
94-
95-
# Test create user
9676
curl -s -X POST http://localhost/users \
9777
-H "Content-Type: application/json" \
9878
&& echo "✓ Create event works"
99-
100-
# Test create event
10179
curl -s -X POST http://localhost/events \
10280
-H "Content-Type: application/json" \
10381
-d "{\"user_id\":1,\"event_type\":\"click\",\"timestamp\":\"2025-06-10T12:00:00Z\",\"metadata\":{\"page\":\"/test\"}}" \
10482
&& echo "✓ Create event works"
105-
106-
# Test get events
10783
curl -f "http://localhost/events?page=1&limit=10" && echo "✓ Get events works"
108-
109-
# Test get user events
11084
curl -f "http://localhost/users/events?user_id=$USER_ID&limit=10" && echo "✓ Get user events works"
111-
112-
# Test get total events
11385
curl -f "http://localhost/events/total" && echo "✓ Get total events count works"
11486
11587
- name: Cleanup
11688
if: always()
117-
run: make down
89+
run: make clean

.gitignore

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
/.idea
2-
/var
3-
/vendor
1+
.buildpath
2+
.settings/
3+
.project
4+
*.patch
5+
.idea/
6+
.git/
7+
runtime/
8+
vendor/
9+
.phpintel/
410
.env
11+
.DS_Store
12+
.phpunit*
13+
*.cache
14+
.vscode/
15+
/phpstan.neon
16+
/phpunit.xml
517
.php-cs-fixer.php

.php-cs-fixer.dist.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use PhpCsFixer\Finder;
77

88
$finder = Finder::create()
9-
->in(__DIR__ . '/src')
9+
->in(__DIR__ . '/app')
1010
->name('*.php')
1111
->ignoreDotFiles(true)
1212
->ignoreVCS(true);
@@ -71,4 +71,4 @@
7171
],
7272
])
7373
->setFinder($finder)
74-
->setCacheFile(__DIR__ . '/var/cache/.php-cs-fixer.cache');
74+
->setCacheFile(__DIR__ . '/runtime/caches/.php-cs-fixer.cache');

.phpstorm.meta.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace PHPSTORM_META {
4+
// Reflect
5+
override(\Psr\Container\ContainerInterface::get(0), map(['' => '@']));
6+
override(\Hyperf\Context\Context::get(0), map(['' => '@']));
7+
override(\make(0), map(['' => '@']));
8+
override(\di(0), map(['' => '@']));
9+
override(\Hyperf\Support\make(0), map(['' => '@']));
10+
override(\Hyperf\Support\optional(0), type(0));
11+
override(\Hyperf\Tappable\tap(0), type(0));
12+
}

0 commit comments

Comments
 (0)