11<?php
22
3+ // Helper functions para compatibilidade
4+ if (!function_exists ('env ' )) {
5+ function env (string $ key , $ default = null ) {
6+ return $ _ENV [$ key ] ?? getenv ($ key ) ?: $ default ;
7+ }
8+ }
9+
10+ if (!function_exists ('app_path ' )) {
11+ function app_path (string $ path = '' ): string {
12+ $ basePath = dirname (__DIR__ , 4 ); // Assumindo vendor/package/src/config
13+ return $ basePath . '/app ' . ($ path ? '/ ' . ltrim ($ path , '/ ' ) : '' );
14+ }
15+ }
16+
17+ if (!function_exists ('database_path ' )) {
18+ function database_path (string $ path = '' ): string {
19+ $ basePath = dirname (__DIR__ , 4 );
20+ return $ basePath . '/database ' . ($ path ? '/ ' . ltrim ($ path , '/ ' ) : '' );
21+ }
22+ }
23+
24+ if (!function_exists ('config_path ' )) {
25+ function config_path (string $ path = '' ): string {
26+ $ basePath = dirname (__DIR__ , 4 );
27+ return $ basePath . '/config ' . ($ path ? '/ ' . ltrim ($ path , '/ ' ) : '' );
28+ }
29+ }
30+
331return [
4- // CORREÇÃO: Configuração de database mais completa
32+ // CORREÇÃO: Configuração de database mais robusta
533 'database ' => [
634 'default ' => env ('DB_CONNECTION ' , 'mysql ' ),
735 'databases ' => [
1543 'database ' => env ('DB_DATABASE ' ),
1644 'username ' => env ('DB_USERNAME ' ),
1745 'password ' => env ('DB_PASSWORD ' , '' ),
18- 'charset ' => ' utf8mb4 ' ,
19- 'collation ' => ' utf8mb4_unicode_ci ' ,
46+ 'charset ' => env ( ' DB_CHARSET ' , ' utf8mb4 ') ,
47+ 'collation ' => env ( ' DB_COLLATION ' , ' utf8mb4_unicode_ci ') ,
2048 'timezone ' => env ('DB_TIMEZONE ' , '+00:00 ' ),
2149 'options ' => [
2250 PDO ::ATTR_ERRMODE => PDO ::ERRMODE_EXCEPTION ,
2351 PDO ::ATTR_DEFAULT_FETCH_MODE => PDO ::FETCH_ASSOC ,
2452 PDO ::ATTR_EMULATE_PREPARES => false ,
2553 PDO ::ATTR_STRINGIFY_FETCHES => false ,
26- PDO ::MYSQL_ATTR_USE_BUFFERED_QUERY => true ,
2754 ]
2855 ],
2956 'postgres ' => [
3360 'database ' => env ('DB_DATABASE ' ),
3461 'username ' => env ('DB_USERNAME ' ),
3562 'password ' => env ('DB_PASSWORD ' , '' ),
36- 'charset ' => ' utf8 ' ,
63+ 'charset ' => env ( ' DB_CHARSET ' , ' utf8 ') ,
3764 'timezone ' => env ('DB_TIMEZONE ' , 'UTC ' ),
3865 ],
3966 'sqlite ' => [
4067 'driver ' => 'sqlite ' ,
4168 'database ' => env ('DB_DATABASE ' , database_path ('database.sqlite ' )),
42- 'foreign_key_constraints ' => true ,
69+ 'foreign_key_constraints ' => env ( ' DB_FOREIGN_KEYS ' , true ) ,
4370 ]
4471 ]
4572 ],
4673
47- // CORREÇÃO: Configuração de entidades melhorada
74+ // CORREÇÃO: Configuração de entidades com fallbacks
4875 'entities ' => [
4976 'directories ' => [
5077 app_path ('Models ' ),
51- app_path ('Entities ' )
78+ app_path ('Entities ' ),
79+ // Fallback para estrutura alternativa
80+ dirname (__DIR__ , 4 ) . '/src/Models ' ,
5281 ],
53- 'namespace ' => ' App \\Models '
82+ 'namespace ' => env ( ' CYCLE_ENTITY_NAMESPACE ' , ' App \\Models ')
5483 ],
5584
56- // CORREÇÃO: Schema com mais opções
85+ // CORREÇÃO: Schema com configurações mais detalhadas
5786 'schema ' => [
58- 'cache ' => env ('CYCLE_SCHEMA_CACHE ' , true ),
59- 'cache_key ' => 'cycle_schema ' ,
60- 'auto_sync ' => env ('CYCLE_AUTO_SYNC ' , false ),
61- 'strict ' => env ('CYCLE_SCHEMA_STRICT ' , false ),
62- 'warmup ' => env ('CYCLE_WARMUP ' , true )
87+ 'cache ' => (bool ) env ('CYCLE_SCHEMA_CACHE ' , true ),
88+ 'cache_key ' => env ('CYCLE_CACHE_KEY ' , 'cycle_schema ' ),
89+ 'auto_sync ' => (bool ) env ('CYCLE_AUTO_SYNC ' , false ),
90+ 'strict ' => (bool ) env ('CYCLE_SCHEMA_STRICT ' , false ),
91+ 'warmup ' => (bool ) env ('CYCLE_WARMUP ' , true ),
92+
93+ // NOVO: Configurações específicas de schema
94+ 'generators ' => [
95+ 'reset_tables ' => true ,
96+ 'validate_entities ' => true ,
97+ 'render_tables ' => true ,
98+ 'render_relations ' => true ,
99+ ]
63100 ],
64101
65- // CORREÇÃO: Migrations melhoradas
102+ // CORREÇÃO: Migrations com configurações expandidas
66103 'migrations ' => [
67- 'directory ' => database_path ('migrations ' ),
68- 'table ' => 'cycle_migrations ' ,
69- 'safe ' => env ('CYCLE_SAFE_MIGRATIONS ' , true ),
70- 'auto_run ' => env ('CYCLE_AUTO_MIGRATE ' , false )
104+ 'directory ' => env ('CYCLE_MIGRATIONS_PATH ' , database_path ('migrations ' )),
105+ 'table ' => env ('CYCLE_MIGRATIONS_TABLE ' , 'cycle_migrations ' ),
106+ 'namespace ' => env ('CYCLE_MIGRATIONS_NAMESPACE ' , 'Database \\Migrations ' ),
107+ 'safe ' => (bool ) env ('CYCLE_SAFE_MIGRATIONS ' , true ),
108+ 'auto_run ' => (bool ) env ('CYCLE_AUTO_MIGRATE ' , false )
71109 ],
72110
73- // NOVO: Performance settings
111+ // NOVO: Performance settings expandidas
74112 'performance ' => [
75- 'query_cache ' => env ('CYCLE_QUERY_CACHE ' , false ),
76- 'lazy_loading ' => env ('CYCLE_LAZY_LOADING ' , true ),
77- 'collection_factory ' => 'array '
113+ 'query_cache ' => (bool ) env ('CYCLE_QUERY_CACHE ' , false ),
114+ 'lazy_loading ' => (bool ) env ('CYCLE_LAZY_LOADING ' , true ),
115+ 'collection_factory ' => env ('CYCLE_COLLECTION_FACTORY ' , 'array ' ),
116+ 'preload_relations ' => (bool ) env ('CYCLE_PRELOAD_RELATIONS ' , false ),
117+
118+ // Connection pooling
119+ 'connection_pool ' => [
120+ 'min_connections ' => (int ) env ('CYCLE_MIN_CONNECTIONS ' , 1 ),
121+ 'max_connections ' => (int ) env ('CYCLE_MAX_CONNECTIONS ' , 10 ),
122+ 'idle_timeout ' => (int ) env ('CYCLE_IDLE_TIMEOUT ' , 60 ),
123+ ]
78124 ],
79125
80- // NOVO: Development settings
126+ // NOVO: Development settings expandidas
81127 'development ' => [
82- 'log_queries ' => env ('CYCLE_LOG_QUERIES ' , false ),
128+ 'log_queries ' => ( bool ) env ('CYCLE_LOG_QUERIES ' , false ),
83129 'slow_query_threshold ' => (int ) env ('CYCLE_SLOW_QUERY_MS ' , 100 ),
84- 'debug_mode ' => env ('CYCLE_DEBUG ' , false )
130+ 'debug_mode ' => (bool ) env ('CYCLE_DEBUG ' , false ),
131+ 'profile_queries ' => (bool ) env ('CYCLE_PROFILE_QUERIES ' , false ),
132+
133+ // Schema validation
134+ 'validate_schema_on_boot ' => (bool ) env ('CYCLE_VALIDATE_SCHEMA ' , false ),
135+ 'schema_validation_strict ' => (bool ) env ('CYCLE_SCHEMA_VALIDATION_STRICT ' , false ),
136+ ],
137+
138+ // NOVO: Security settings
139+ 'security ' => [
140+ 'encrypt_connection ' => (bool ) env ('DB_ENCRYPT ' , false ),
141+ 'verify_ssl ' => (bool ) env ('DB_VERIFY_SSL ' , true ),
142+ 'connection_timeout ' => (int ) env ('DB_TIMEOUT ' , 30 ),
143+
144+ // Query security
145+ 'disable_raw_queries ' => (bool ) env ('CYCLE_DISABLE_RAW_QUERIES ' , false ),
146+ 'audit_queries ' => (bool ) env ('CYCLE_AUDIT_QUERIES ' , false ),
147+ ],
148+
149+ // NOVO: Monitoring and observability
150+ 'monitoring ' => [
151+ 'metrics_enabled ' => (bool ) env ('CYCLE_METRICS_ENABLED ' , false ),
152+ 'slow_query_log ' => (bool ) env ('CYCLE_SLOW_QUERY_LOG ' , false ),
153+ 'query_stats ' => (bool ) env ('CYCLE_QUERY_STATS ' , false ),
154+
155+ // Health checks
156+ 'health_check_enabled ' => (bool ) env ('CYCLE_HEALTH_CHECK ' , true ),
157+ 'health_check_interval ' => (int ) env ('CYCLE_HEALTH_CHECK_INTERVAL ' , 300 ),
85158 ]
86- ];
159+ ];
0 commit comments