Skip to content

Commit 8f48c39

Browse files
committed
sync config from app-api to app-basic
1 parent 492d88b commit 8f48c39

File tree

2 files changed

+15
-33
lines changed

2 files changed

+15
-33
lines changed

examples/app-basic/config/common.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,14 @@
2424
'poolWaitTimeout' => (float)(getenv('YII_REDIS_POOL_WAIT_TIMEOUT') ?: 5.0),
2525
],
2626
'cache' => [
27-
'class' => \yii\caching\ArrayCache::class,
27+
// TODO: Use RedisCache for production
28+
'class' => \yii\caching\DummyCache::class,
2829
],
2930
'queue' => [
3031
'class' => \Dacheng\Yii2\Swoole\Queue\CoroutineRedisQueue::class,
31-
'redis' => 'redis', // Reference to redis component
32-
'channel' => 'queue', // Redis key prefix for queue data
33-
34-
// Concurrency settings:
35-
// - Set to 1 for serial processing (safe, compatible with all job types)
36-
// - Set to 10-50 for I/O intensive jobs (database queries, API calls, file operations)
37-
// - Set to 100+ for lightweight jobs with minimal processing
38-
// Note: Each concurrent worker runs in a separate coroutine
32+
'redis' => 'redis',
33+
'channel' => 'queue',
3934
'concurrency' => (int)(getenv('YII_QUEUE_CONCURRENCY') ?: 10),
40-
41-
// Inline execution (recommended for coroutine context):
42-
// - true: Execute jobs in the same process (faster, lower overhead)
43-
// - false: Fork child processes for each job (slower, better isolation)
4435
'executeInline' => true,
4536
],
4637
'db' => [
@@ -51,8 +42,8 @@
5142
'charset' => 'utf8mb4',
5243
'poolMaxActive' => (int)(getenv('YII_DB_POOL_MAX_ACTIVE') ?: 10),
5344
'poolWaitTimeout' => (float)(getenv('YII_DB_POOL_WAIT_TIMEOUT') ?: 5.0),
54-
'enableSchemaCache' => true,
55-
'schemaCacheDuration' => (int)(getenv('YII_DB_SCHEMA_CACHE_DURATION') ?: 3600),
45+
'enableSchemaCache' => false,
46+
'schemaCacheDuration' => 0,
5647
'schemaCache' => 'cache',
5748
],
5849
'swooleHttpServer' => [

examples/app-basic/config/web.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
'components' => [
1515
'request' => [
1616
'cookieValidationKey' => 'test-secret-key',
17-
'enableCsrfValidation' => false, // Disable CSRF for API testing
17+
'enableCsrfValidation' => false,
1818
'baseUrl' => '',
1919
'scriptUrl' => '/index.php',
20+
'parsers' => [
21+
'application/json' => 'yii\web\JsonParser',
22+
],
2023
],
2124
'assetManager' => [
2225
'basePath' => dirname(__DIR__) . '/web/assets',
@@ -27,7 +30,6 @@
2730
'redis' => 'redis',
2831
'keyPrefix' => 'phpsession:',
2932
'timeout' => (int)(getenv('YII_SESSION_TIMEOUT') ?: 1440),
30-
'autoCloseOnCoroutineEnd' => false, // Disable auto-close to prevent conflicts
3133
],
3234
'user' => [
3335
'class' => \Dacheng\Yii2\Swoole\User\CoroutineUser::class,
@@ -48,18 +50,18 @@
4850
'targets' => [
4951
[
5052
'class' => \Dacheng\Yii2\Swoole\Log\CoroutineFileTarget::class,
51-
'levels' => ['error', 'warning', 'info'],
53+
'levels' => ['error', 'warning'],
5254
'exportInterval' => 1,
5355
'logFile' => '@runtime/logs/app.log',
5456
'channelSize' => (int)(getenv('YII_LOG_CHANNEL_SIZE') ?: 10000),
5557
'pushTimeout' => 0.5,
56-
'batchSize' => 1000, // Packets per batch write
57-
'maxFileSize' => 10240, // 10MB
58+
'batchSize' => 1000,
59+
'maxFileSize' => 10240,
5860
'maxLogFiles' => 5,
5961
'enableRotation' => true,
6062
'categories' => [],
6163
'except' => [],
62-
'logVars' => [],
64+
'logVars' => false,
6365
'microtime' => true,
6466
],
6567
],
@@ -79,28 +81,17 @@
7981
$config = \yii\helpers\ArrayHelper::merge($commonConfig, $config);
8082

8183
if (YII_ENV_DEV) {
82-
// configuration adjustments for 'dev' environment when optional packages are present
83-
84-
// Debug module is disabled for Swoole compatibility
85-
// TODO: Fix debug module to work properly with Swoole coroutines
86-
/*
8784
if (class_exists('yii\\debug\\Module')) {
8885
$config['bootstrap'][] = 'debug';
8986
$config['modules']['debug'] = [
90-
'class' => \Dacheng\Yii2\Swoole\Debug\CoroutineDebugModule::class,
91-
'allowedIPs' => ['127.0.0.1', '::1'],
92-
'historySize' => 50,
93-
'traceLine' => '<a href="file://{file}" title="{file}">{file}:{line}</a>',
87+
'class' => 'yii\\debug\\Module',
9488
];
9589
}
96-
*/
9790

9891
if (class_exists('yii\\gii\\Module')) {
9992
$config['bootstrap'][] = 'gii';
10093
$config['modules']['gii'] = [
10194
'class' => 'yii\\gii\\Module',
102-
// uncomment the following to add your IP if you are not connecting from localhost.
103-
//'allowedIPs' => ['127.0.0.1', '::1'],
10495
];
10596
}
10697
}

0 commit comments

Comments
 (0)