Skip to content

Commit 6845d9a

Browse files
committed
feat: Atualiza a extensão Cycle ORM para Express-PHP com melhorias de configuração, validação e performance
1 parent 29ef930 commit 6845d9a

9 files changed

Lines changed: 615 additions & 238 deletions

File tree

composer.json

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,44 @@
11
{
2-
"name": "express-php/cycle-orm-extension",
3-
"description": "Cycle ORM integration for Express-PHP microframework",
2+
"name": "cafernandes/express-php-cycle-orm-extension",
3+
"description": "Integração completa do Cycle ORM com o microframework Express-PHP",
44
"keywords": ["express-php", "cycle-orm", "database", "orm", "microframework"],
55
"type": "library",
66
"license": "MIT",
77
"authors": [
88
{
99
"name": "Caio Alberto Fernandes",
10-
"email": "caio.fernandes@example.com"
10+
"homepage": "https://github.com/CAFernandes"
1111
}
1212
],
1313
"require": {
1414
"php": "^8.1",
1515
"cafernandes/express-php": "^2.1",
16-
"cycle/orm": "^2.0",
17-
"cycle/annotated": "^3.0",
18-
"cycle/migrations": "^3.0",
19-
"cycle/schema-builder": "^2.0"
16+
"cycle/orm": "^2.7",
17+
"cycle/annotated": "^3.4",
18+
"cycle/migrations": "^3.2",
19+
"cycle/schema-builder": "^2.7",
20+
"spiral/tokenizer": "^3.4"
2021
},
2122
"require-dev": {
2223
"phpunit/phpunit": "^10.0",
23-
"phpstan/phpstan": "^1.0",
24-
"squizlabs/php_codesniffer": "^3.0"
24+
"phpstan/phpstan": "^1.10",
25+
"squizlabs/php_codesniffer": "^3.7"
2526
},
2627
"autoload": {
2728
"psr-4": {
28-
"ExpressPHP\\CycleORM\\": "src/"
29+
"CAFernandes\\ExpressPHP\\CycleORM\\": "src/"
2930
}
3031
},
3132
"autoload-dev": {
3233
"psr-4": {
33-
"ExpressPHP\\CycleORM\\Tests\\": "tests/"
34+
"CAFernandes\\ExpressPHP\\CycleORM\\Tests\\": "tests/"
3435
}
3536
},
3637
"extra": {
3738
"express-php": {
3839
"providers": [
39-
"ExpressPHP\\CycleORM\\CycleServiceProvider"
40+
"CAFernandes\\ExpressPHP\\CycleORM\\CycleServiceProvider"
4041
]
4142
}
42-
},
43-
"scripts": {
44-
"test": "phpunit",
45-
"test-coverage": "phpunit --coverage-html coverage",
46-
"phpstan": "phpstan analyse src --level=9",
47-
"cs-check": "phpcs src --standard=PSR12",
48-
"cs-fix": "phpcbf src --standard=PSR12"
4943
}
5044
}

config/cycle.php

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
return [
4-
// Database configuration
4+
// CORREÇÃO: Configuração de database mais completa
55
'database' => [
66
'default' => env('DB_CONNECTION', 'mysql'),
77
'databases' => [
@@ -11,51 +11,76 @@
1111
'mysql' => [
1212
'driver' => 'mysql',
1313
'host' => env('DB_HOST', 'localhost'),
14-
'port' => env('DB_PORT', 3306),
15-
'database' => env('DB_DATABASE', 'express_db'),
16-
'username' => env('DB_USERNAME', 'root'),
14+
'port' => (int) env('DB_PORT', 3306),
15+
'database' => env('DB_DATABASE'),
16+
'username' => env('DB_USERNAME'),
1717
'password' => env('DB_PASSWORD', ''),
1818
'charset' => 'utf8mb4',
1919
'collation' => 'utf8mb4_unicode_ci',
20+
'timezone' => env('DB_TIMEZONE', '+00:00'),
2021
'options' => [
2122
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
2223
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
2324
PDO::ATTR_EMULATE_PREPARES => false,
25+
PDO::ATTR_STRINGIFY_FETCHES => false,
26+
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
2427
]
2528
],
29+
'postgres' => [
30+
'driver' => 'postgres',
31+
'host' => env('DB_HOST', 'localhost'),
32+
'port' => (int) env('DB_PORT', 5432),
33+
'database' => env('DB_DATABASE'),
34+
'username' => env('DB_USERNAME'),
35+
'password' => env('DB_PASSWORD', ''),
36+
'charset' => 'utf8',
37+
'timezone' => env('DB_TIMEZONE', 'UTC'),
38+
],
2639
'sqlite' => [
2740
'driver' => 'sqlite',
28-
'database' => env('DB_DATABASE', 'database/database.sqlite'),
29-
'options' => [
30-
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
31-
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
32-
]
41+
'database' => env('DB_DATABASE', database_path('database.sqlite')),
42+
'foreign_key_constraints' => true,
3343
]
3444
]
3545
],
3646

37-
// Entity configuration
47+
// CORREÇÃO: Configuração de entidades melhorada
3848
'entities' => [
39-
'directories' => ['app/Models'],
49+
'directories' => [
50+
app_path('Models'),
51+
app_path('Entities')
52+
],
4053
'namespace' => 'App\\Models'
4154
],
4255

43-
// Schema configuration
56+
// CORREÇÃO: Schema com mais opções
4457
'schema' => [
4558
'cache' => env('CYCLE_SCHEMA_CACHE', true),
59+
'cache_key' => 'cycle_schema',
4660
'auto_sync' => env('CYCLE_AUTO_SYNC', false),
47-
'strict' => env('CYCLE_SCHEMA_STRICT', false)
61+
'strict' => env('CYCLE_SCHEMA_STRICT', false),
62+
'warmup' => env('CYCLE_WARMUP', true)
4863
],
4964

50-
// Migration configuration
65+
// CORREÇÃO: Migrations melhoradas
5166
'migrations' => [
52-
'directory' => 'database/migrations',
53-
'table' => 'migrations',
54-
'safe' => env('CYCLE_SAFE_MIGRATIONS', true)
67+
'directory' => database_path('migrations'),
68+
'table' => 'cycle_migrations',
69+
'safe' => env('CYCLE_SAFE_MIGRATIONS', true),
70+
'auto_run' => env('CYCLE_AUTO_MIGRATE', false)
71+
],
72+
73+
// NOVO: Performance settings
74+
'performance' => [
75+
'query_cache' => env('CYCLE_QUERY_CACHE', false),
76+
'lazy_loading' => env('CYCLE_LAZY_LOADING', true),
77+
'collection_factory' => 'array'
5578
],
5679

57-
// Repository configuration
58-
'repositories' => [
59-
'default' => \Cycle\ORM\Select\Repository::class
80+
// NOVO: Development settings
81+
'development' => [
82+
'log_queries' => env('CYCLE_LOG_QUERIES', false),
83+
'slow_query_threshold' => (int) env('CYCLE_SLOW_QUERY_MS', 100),
84+
'debug_mode' => env('CYCLE_DEBUG', false)
6085
]
6186
];

0 commit comments

Comments
 (0)