Skip to content

Commit 10dc781

Browse files
authored
Feature/move cache to redis (#417)
1 parent f70e26c commit 10dc781

File tree

112 files changed

+1779
-1973
lines changed

Some content is hidden

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

112 files changed

+1779
-1973
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ node_modules
44
# Laravel
55
.mcp.json
66
.env.example
7+
.env.testing
78
phpstan.neon
8-
phpunit.xml
9+
phpunit.*.xml
910
rector.php
1011
pint.json
1112
tests

.env.example

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,29 @@ APP_NAME="LaravelCameroun"
22
APP_ENV=local
33
APP_KEY=
44
APP_DEBUG=true
5+
APP_DOMAIN=laravelcm.local
56
APP_URL=http://laravelcm.local
7+
ASSET_URL=https://laravelcm.local
68
APP_LOCALE=fr
9+
APP_FALLBACK_LOCALE=fr
710
APP_PORT=8080
811
APP_SERVICE=laravelcm
9-
FILAMENT_PATH=cp
1012

1113
LOG_CHANNEL=stack
1214
LOG_STACK=single,nightwatch
1315
LOG_LEVEL=debug
1416

17+
RAY_HOST=ray@buggregator
18+
RAY_PORT=8000
19+
SENTRY_LARAVEL_DSN=http://sentry@buggregator:8000/1
20+
SENTRY_TRACES_SAMPLE_RATE=1.0
21+
VAR_DUMPER_FORMAT=server
22+
VAR_DUMPER_SERVER=tcp://buggregator:9912
23+
INSPECTOR_URL=http://inspector@buggregator:8000
24+
INSPECTOR_API_KEY=test
25+
INSPECTOR_INGESTION_KEY=1test
26+
INSPECTOR_ENABLE=true
27+
1528
DB_CONNECTION=pgsql
1629
DB_HOST=pgsql
1730
DB_PORT=5432
@@ -20,10 +33,16 @@ DB_USERNAME=sail
2033
DB_PASSWORD=password
2134

2235
BROADCAST_DRIVER=log
23-
CACHE_DRIVER=file
36+
MEDIA_DISK=media
37+
FILESYSTEM_DISK=${MEDIA_DISK}
38+
FILAMENT_FILESYSTEM_DISK=${MEDIA_DISK}
39+
FILAMENT_PATH=cpanel
40+
2441
QUEUE_CONNECTION=database
42+
BROADCAST_CONNECTION=log
43+
CACHE_DRIVER=file
2544
SESSION_DRIVER=database
26-
SESSION_LIFETIME=120
45+
SESSION_LIFETIME=1400
2746

2847
MEMCACHED_HOST=127.0.0.1
2948

@@ -41,10 +60,13 @@ MAIL_FROM_ADDRESS=no-reply@laravel.cm
4160
MAIL_FROM_NAME="${APP_NAME}"
4261
MAIL_SUPPORT=mail-support@laravel.cm
4362

44-
AWS_ACCESS_KEY_ID=
45-
AWS_SECRET_ACCESS_KEY=
63+
AWS_ACCESS_KEY_ID=sail
64+
AWS_SECRET_ACCESS_KEY=password
4665
AWS_DEFAULT_REGION=us-east-1
47-
AWS_BUCKET=
66+
AWS_BUCKET=laravelcm
67+
AWS_ENDPOINT="http://minio:9000"
68+
AWS_URL="http://localhost:9000/laravelcm"
69+
AWS_USE_PATH_STYLE_ENDPOINT=true
4870

4971
PUSHER_APP_ID=
5072
PUSHER_APP_KEY=
@@ -57,39 +79,27 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
5779
GITHUB_CLIENT_ID=
5880
GITHUB_CLIENT_SECRET=
5981
GITHUB_REDIRECT=${APP_URL}/auth/github/callback
60-
82+
GITHUB_FINE_GRAINED_TOKEN=
6183
MARKDOWNX_GIPHY_API_KEY=
6284
TORCHLIGHT_TOKEN=
6385
TORCHLIGHT_THEME=moonlight-ii
64-
UNSPLASH_ACCESS_KEY=
65-
6686
TELEGRAM_BOT_TOKEN=
6787
TELEGRAM_CHANNEL=
68-
69-
MEDIA_DISK=media
70-
FILAMENT_FILESYSTEM_DISK=${MEDIA_DISK}
71-
72-
NOTCHPAY_PUBLIC_KEY=
73-
7488
TWITTER_CONSUMER_KEY=your-consumer-key
7589
TWITTER_CONSUMER_SECRET=your-consumer-secret
7690
TWITTER_ACCESS_TOKEN=your-accesss_token
7791
TWITTER_ACCESS_SECRET=your-access-token-secret
78-
79-
GOOGLE_RECAPTCHA_SITE_KEY=your-recaptcha-site-key
80-
GOOGLE_RECAPTCHA_SECRET_KEY=your-secret-key
81-
82-
GITHUB_FINE_GRAINED_TOKEN=
92+
UNSPLASH_ACCESS_KEY=
93+
NOTCHPAY_PUBLIC_KEY=
94+
NIGHTWATCH_TOKEN=
95+
NIGHTWATCH_REQUEST_SAMPLE_RATE=0.1
8396

8497
SCOUT_DRIVER=typesense
8598
TYPESENSE_HOST=typesense
8699
TYPESENSE_PORT=8108
87100
TYPESENSE_PROTOCOL=http
88101
TYPESENSE_API_KEY=xyz
89102

90-
NIGHTWATCH_TOKEN=
91-
NIGHTWATCH_REQUEST_SAMPLE_RATE=0.1
92-
93103
# SSH Tunnel Configuration for Database Migration
94104
SSH_TUNNEL_USER=
95105
SSH_TUNNEL_HOSTNAME=

.env.testing

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
APP_NAME="LaravelCameroun"
2+
APP_ENV=testing
3+
APP_KEY=base64:NXoQgjw2ZlOxnGbo5ZRhYgTdM6xLYsgYElNAgcTQJkE=
4+
APP_DEBUG=false
5+
APP_DOMAIN=laravelcm.test
6+
APP_URL=http://laravelcm.test
7+
ASSET_URL=http://laravelcm.test
8+
APP_LOCALE=fr
9+
APP_FALLBACK_LOCALE=fr
10+
11+
LOG_CHANNEL=stack
12+
LOG_STACK=single
13+
LOG_LEVEL=error
14+
15+
# Base de données PostgreSQL pour les tests
16+
DB_CONNECTION=pgsql
17+
DB_HOST=pgsql
18+
DB_PORT=5432
19+
DB_DATABASE=testing
20+
DB_USERNAME=sail
21+
DB_PASSWORD=password
22+
23+
# Cache et sessions pour les tests
24+
CACHE_DRIVER=array
25+
SESSION_DRIVER=array
26+
QUEUE_CONNECTION=sync
27+
28+
# Mail en mode array pour les tests
29+
MAIL_MAILER=array
30+
31+
# Désactiver les services externes en mode test
32+
TELESCOPE_ENABLED=false
33+
RAY_ENABLED=false
34+
SENTRY_LARAVEL_DSN=
35+
INSPECTOR_ENABLE=false
36+
37+
# Optimisations pour les tests
38+
BCRYPT_ROUNDS=4
39+
40+
# Répertoires pour les tests (éviter les problèmes de permissions)
41+
VIEW_COMPILED_PATH=/tmp/views
42+
LOG_CHANNEL=null

.github/actions/setup/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ runs:
88
uses: shivammathur/setup-php@v2
99
with:
1010
php-version: "8.4"
11-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, bcmath, soap, intl, gd, exif, iconv, imagick
11+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, bcmath, soap, intl, gd, exif, iconv, imagick
1212
tools: composer:v2
1313
coverage: none
1414
- name: ℹ Setup Problem Matches

.github/workflows/tests.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ jobs:
1515
pest:
1616
runs-on: ubuntu-22.04
1717

18+
services:
19+
postgres:
20+
image: postgres:17-alpine
21+
env:
22+
POSTGRES_PASSWORD: password
23+
POSTGRES_USER: sail
24+
POSTGRES_DB: testing
25+
ports:
26+
- 5432:5432
27+
options: >-
28+
--health-cmd pg_isready
29+
--health-interval 10s
30+
--health-timeout 5s
31+
--health-retries 5
32+
1833
steps:
1934
- name: 👀 Checkout
2035
uses: actions/checkout@v5
@@ -27,4 +42,4 @@ jobs:
2742
- name: 🧱 Build JS Dependencies
2843
run: yarn build
2944
- name: 🕵️‍♂️ Run Pest Tests
30-
run: ./vendor/bin/pest
45+
run: ./vendor/bin/pest --configuration=phpunit.ci.xml --parallel --processes=4 --bail

Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ FROM ghcr.io/yieldstudio/php:${PHP_VERSION}-frankenphp AS base
88

99
ENV HEALTHCHECK_PATH="/up"
1010

11-
## Uncomment if you need to install additional PHP extensions
12-
# USER root
13-
# RUN install-php-extensions bcmath gd
14-
1511
############################################
1612
# Development Image
1713
############################################

app/Console/Commands/AssignUserRole.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function handle(): void
1717
{
1818
$this->info('Assigning user role to all users...');
1919

20-
foreach (User::withoutRole()->get() as $user) {
20+
foreach (User::query()->scopes('withoutRole')->get() as $user) {
2121
$user->assignRole('user');
2222
}
2323

app/Console/Commands/PublishArticles.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public function handle(): void
2121

2222
foreach ($articles as $article) {
2323
/** @var Article $article */
24-
$article->published_at = $article->submitted_at;
25-
$article->save();
24+
$article->update([
25+
'published_at' => $article->submitted_at,
26+
]);
2627
}
2728

2829
$count = $articles->count();

app/Console/Commands/SendUnVerifiedMails.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class SendUnVerifiedMails extends Command
1717

1818
public function handle(): void
1919
{
20-
foreach (User::unVerifiedUsers()->get() as $user) {
20+
foreach (User::query()->scopes('unVerifiedUsers')->get() as $user) {
2121
Mail::to($user)->send(new SendMailToUnVerifiedUsers($user));
2222
}
2323
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Contracts;
6+
7+
interface HasCachedMediaInterface
8+
{
9+
public function getCacheKey(string $collection): string;
10+
11+
public function getCacheTtl(): \DateTimeInterface;
12+
13+
public function flushMediaCache(?string $collection = null): void;
14+
15+
public function getMediaCollections(): array;
16+
}

0 commit comments

Comments
 (0)