Skip to content

Commit 2d80e7a

Browse files
committed
chore: update workbench testing setup for S3
1 parent 21842df commit 2d80e7a

File tree

4 files changed

+242
-1
lines changed

4 files changed

+242
-1
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
"spatie/laravel-package-tools": "^1.16"
2121
},
2222
"require-dev": {
23+
"larastan/larastan": "^2.9||^3.0",
2324
"laravel/pint": "^1.14",
25+
"league/flysystem-aws-s3-v3": "^3.0",
2426
"nunomaduro/collision": "^8.1.1||^7.10.0",
25-
"larastan/larastan": "^2.9||^3.0",
2627
"orchestra/testbench": "^10.0.0||^9.0.0||^8.22.0",
2728
"pestphp/pest": "^3.0",
2829
"pestphp/pest-plugin-arch": "^3.0",

testbench.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ workbench:
2020
components: false
2121
factories: true
2222
views: false
23+
config: true
2324
build:
2425
- asset-publish
2526
- create-sqlite-db

workbench/config/filesystems.php

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Default Filesystem Disk
8+
|--------------------------------------------------------------------------
9+
|
10+
| Here you may specify the default filesystem disk that should be used
11+
| by the framework. The "local" disk, as well as a variety of cloud
12+
| based disks are available to your application for file storage.
13+
|
14+
*/
15+
16+
'default' => env('FILESYSTEM_DISK', 'local'),
17+
18+
/*
19+
|--------------------------------------------------------------------------
20+
| Filesystem Disks
21+
|--------------------------------------------------------------------------
22+
|
23+
| Below you may configure as many filesystem disks as necessary, and you
24+
| may even configure multiple disks for the same driver. Examples for
25+
| most supported storage drivers are configured here for reference.
26+
|
27+
| Supported drivers: "local", "ftp", "sftp", "s3"
28+
|
29+
*/
30+
31+
'disks' => [
32+
33+
'local' => [
34+
'driver' => 'local',
35+
'root' => storage_path('app/private'),
36+
'serve' => true,
37+
'throw' => false,
38+
'report' => false,
39+
],
40+
41+
'public' => [
42+
'driver' => 'local',
43+
'root' => storage_path('app/public'),
44+
'url' => env('APP_URL').'/storage',
45+
'visibility' => 'public',
46+
'throw' => false,
47+
'report' => false,
48+
],
49+
50+
's3' => [
51+
'driver' => 's3',
52+
'key' => env('AWS_ACCESS_KEY_ID'),
53+
'secret' => env('AWS_SECRET_ACCESS_KEY'),
54+
'region' => env('AWS_DEFAULT_REGION'),
55+
'bucket' => env('AWS_BUCKET'),
56+
'url' => env('AWS_URL'),
57+
'endpoint' => env('AWS_ENDPOINT'),
58+
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
59+
'throw' => false,
60+
'report' => false,
61+
],
62+
63+
'r2' => [
64+
'driver' => 's3',
65+
'key' => env('CLOUDFLARE_R2_ACCESS_KEY'),
66+
'secret' => env('CLOUDFLARE_R2_SECRET_KEY'),
67+
'region' => 'us-east-1',
68+
'bucket' => env('CLOUDFLARE_R2_BUCKET'),
69+
'endpoint' => env('CLOUDFLARE_R2_ENDPOINT'),
70+
'url' => env('CLOUDFLARE_R2_URL'),
71+
'use_path_style_endpoint' => env('CLOUDFLARE_R2_USE_PATH_STYLE_ENDPOINT', false),
72+
'throw' => false,
73+
],
74+
75+
],
76+
77+
/*
78+
|--------------------------------------------------------------------------
79+
| Symbolic Links
80+
|--------------------------------------------------------------------------
81+
|
82+
| Here you may configure the symbolic links that will be created when the
83+
| `storage:link` Artisan command is executed. The array keys should be
84+
| the locations of the links and the values should be their targets.
85+
|
86+
*/
87+
88+
'links' => [
89+
public_path('storage') => storage_path('app/public'),
90+
],
91+
92+
];
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Source Directories
7+
|--------------------------------------------------------------------------
8+
|
9+
| Here you may configure the directories from which the image transformer
10+
| is allowed to serve images. For security reasons, it is recommended
11+
| to only allow directories which are already publicly accessible.
12+
|
13+
| Important: The public storage directory should be addressed directly via
14+
| storage('app/public') instead of the public_path('storage') link.
15+
|
16+
| You can also use any Laravel Filesystem disk (e.g. s3) by providing an
17+
| array configuration with 'disk' and an optional 'prefix'.
18+
|
19+
*/
20+
21+
'source_directories' => [
22+
'images-test' => public_path('images'),
23+
'storage' => storage_path('app/public/images'),
24+
'remote' => ['disk' => 'r2'],
25+
],
26+
27+
/*
28+
|--------------------------------------------------------------------------
29+
| Default Source Directory
30+
|--------------------------------------------------------------------------
31+
|
32+
| Below you may configure the default source directory which is used when
33+
| no specific path prefix is provided in the URL. This should be one of
34+
| the keys from the source_directories array.
35+
|
36+
*/
37+
38+
'default_source_directory' => env('IMAGE_TRANSFORM_DEFAULT_SOURCE_DIRECTORY', 'images-test'),
39+
40+
/*
41+
|--------------------------------------------------------------------------
42+
| Route Prefix
43+
|--------------------------------------------------------------------------
44+
|
45+
| Here you may configure the route prefix of the image transformer.
46+
|
47+
*/
48+
49+
'route_prefix' => env('IMAGE_TRANSFORM_ROUTE_PREFIX', 'image-transform'),
50+
51+
/*
52+
|--------------------------------------------------------------------------
53+
| Enabled Options
54+
|--------------------------------------------------------------------------
55+
|
56+
| Here you may configure the options which are enabled for the image
57+
| transformer.
58+
|
59+
*/
60+
61+
'enabled_options' => env('IMAGE_TRANSFORM_ENABLED_OPTIONS', [
62+
'width',
63+
'height',
64+
'format',
65+
'quality',
66+
'flip',
67+
'contrast',
68+
'version',
69+
'background',
70+
// 'blur'
71+
]),
72+
73+
/*
74+
|--------------------------------------------------------------------------
75+
| Image Cache
76+
|--------------------------------------------------------------------------
77+
|
78+
| Here you may configure the image cache settings. The cache is used to
79+
| store the transformed images for a certain amount of time. This is
80+
| useful to prevent reprocessing the same image multiple times.
81+
| The cache is stored in the configured cache disk.
82+
|
83+
*/
84+
85+
'cache' => [
86+
'enabled' => env('IMAGE_TRANSFORM_CACHE_ENABLED', true),
87+
'lifetime' => env('IMAGE_TRANSFORM_CACHE_LIFETIME', 60 * 24 * 7), // 7 days
88+
'disk' => env('IMAGE_TRANSFORM_CACHE_DISK', 'r2'),
89+
'max_size_mb' => env('IMAGE_TRANSFORM_CACHE_MAX_SIZE_MB', 100), // 100 MB
90+
'clear_to_percent' => env('IMAGE_TRANSFORM_CACHE_CLEAR_TO_PERCENT', 80), // 80% of max size
91+
],
92+
93+
/*
94+
|--------------------------------------------------------------------------
95+
| Rate Limit
96+
|--------------------------------------------------------------------------
97+
|
98+
| Below you may configure the rate limit which is applied for each image
99+
| new transformation by the path and IP address. It is recommended to
100+
| set this to a low value, e.g. 2 requests per minute, to prevent
101+
| abuse.
102+
|
103+
*/
104+
105+
'rate_limit' => [
106+
'enabled' => env('IMAGE_TRANSFORM_RATE_LIMIT_ENABLED', true),
107+
'disabled_for_environments' => env('IMAGE_TRANSFORM_RATE_LIMIT_DISABLED_FOR_ENVIRONMENTS', [
108+
'local',
109+
'testing',
110+
]),
111+
'max_attempts' => env('IMAGE_TRANSFORM_RATE_LIMIT_MAX_REQUESTS', 2),
112+
'decay_seconds' => env('IMAGE_TRANSFORM_RATE_LIMIT_DECAY_SECONDS', 60),
113+
],
114+
115+
/*
116+
|--------------------------------------------------------------------------
117+
| Signed URLs
118+
|--------------------------------------------------------------------------
119+
|
120+
| Below you may configure signed URLs, which can be used to protect image
121+
| transformations from unauthorized access. Signature verification is
122+
| only applied to images from the for_source_directories array.
123+
|
124+
*/
125+
126+
'signed_urls' => [
127+
'enabled' => env('IMAGE_TRANSFORM_SIGNED_URLS_ENABLED', false),
128+
'for_source_directories' => env('IMAGE_TRANSFORM_SIGNED_URLS_FOR_SOURCE_DIRECTORIES', [
129+
//
130+
]),
131+
],
132+
133+
/*
134+
|--------------------------------------------------------------------------
135+
| Response Headers
136+
|--------------------------------------------------------------------------
137+
|
138+
| Below you may configure the response headers which are added to the
139+
| response. This is especially useful for controlling caching behavior
140+
| of CDNs.
141+
|
142+
*/
143+
144+
'headers' => [
145+
'Cache-Control' => env('IMAGE_TRANSFORM_HEADER_CACHE_CONTROL', 'immutable, public, max-age=2592000, s-maxage=2592000'),
146+
],
147+
];

0 commit comments

Comments
 (0)