feat: Add Trello configuration fallback and test command

- Add fallback env parsing directly from .env file in config/trello.php
- Fixes issue where cached config prevents env() from reading .env values
- Add artisan trello:test command to diagnose Trello configuration
- Test command checks API credentials, board/list IDs, and connectivity
- Test successfully creates and moves a test Trello card
This commit is contained in:
twotalesanimation
2026-01-02 15:36:27 +02:00
parent 783cc88c6d
commit ca7d16da16
58 changed files with 3782 additions and 52 deletions
+40 -25
View File
@@ -1,36 +1,51 @@
<?php
// Load .env file directly if needed
if (!function_exists('env') || env('TRELLO_API_KEY') === null) {
$envFile = __DIR__ . '/../.env';
if (file_exists($envFile)) {
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$env = [];
foreach ($lines as $line) {
if (strpos($line, '=') !== false && strpos($line, '#') !== 0) {
[$key, $value] = explode('=', $line, 2);
$env[trim($key)] = trim($value);
}
}
}
}
return [
'api_key' => env('TRELLO_API_KEY'),
'api_token' => env('TRELLO_API_TOKEN'),
'board_id' => env('TRELLO_BOARD_ID'),
'webhook_secret' => env('TRELLO_WEBHOOK_SECRET'),
'api_key' => env('TRELLO_API_KEY') ?: ($env['TRELLO_API_KEY'] ?? null),
'api_token' => env('TRELLO_API_TOKEN') ?: ($env['TRELLO_API_TOKEN'] ?? null),
'board_id' => env('TRELLO_BOARD_ID') ?: ($env['TRELLO_BOARD_ID'] ?? null),
'webhook_secret' => env('TRELLO_WEBHOOK_SECRET') ?: ($env['TRELLO_WEBHOOK_SECRET'] ?? null),
'lists' => [
'standard' => [
'new_order' => env('TRELLO_LIST_ID_NEW_ORDER'),
'prep' => env('TRELLO_LIST_ID_PREP'),
'printing' => env('TRELLO_LIST_ID_PRINTING'),
'inspection' => env('TRELLO_LIST_ID_INSPECTION'),
'packing' => env('TRELLO_LIST_ID_PACKING'),
'ready_to_ship' => env('TRELLO_LIST_ID_READY_TO_SHIP'),
'awaiting_collection' => env('TRELLO_LIST_ID_AWAITING_COLLECTION'),
'in_transit' => env('TRELLO_LIST_ID_IN_TRANSIT'),
'done' => env('TRELLO_LIST_ID_DONE'),
'new_order' => env('TRELLO_LIST_ID_NEW_ORDER') ?: ($env['TRELLO_LIST_ID_NEW_ORDER'] ?? null),
'prep' => env('TRELLO_LIST_ID_PREP') ?: ($env['TRELLO_LIST_ID_PREP'] ?? null),
'printing' => env('TRELLO_LIST_ID_PRINTING') ?: ($env['TRELLO_LIST_ID_PRINTING'] ?? null),
'inspection' => env('TRELLO_LIST_ID_INSPECTION') ?: ($env['TRELLO_LIST_ID_INSPECTION'] ?? null),
'packing' => env('TRELLO_LIST_ID_PACKING') ?: ($env['TRELLO_LIST_ID_PACKING'] ?? null),
'ready_to_ship' => env('TRELLO_LIST_ID_READY_TO_SHIP') ?: ($env['TRELLO_LIST_ID_READY_TO_SHIP'] ?? null),
'awaiting_collection' => env('TRELLO_LIST_ID_AWAITING_COLLECTION') ?: ($env['TRELLO_LIST_ID_AWAITING_COLLECTION'] ?? null),
'in_transit' => env('TRELLO_LIST_ID_IN_TRANSIT') ?: ($env['TRELLO_LIST_ID_IN_TRANSIT'] ?? null),
'done' => env('TRELLO_LIST_ID_DONE') ?: ($env['TRELLO_LIST_ID_DONE'] ?? null),
],
'custom' => [
'new_custom_order' => env('TRELLO_LIST_ID_NEW_CUSTOM_ORDER'),
'design' => env('TRELLO_LIST_ID_DESIGN'),
'awaiting_approval' => env('TRELLO_LIST_ID_AWAITING_APPROVAL'),
'awaiting_balance' => env('TRELLO_LIST_ID_AWAITING_BALANCE'),
'ready_for_print' => env('TRELLO_LIST_ID_READY_FOR_PRINT'),
'printing' => env('TRELLO_LIST_ID_PRINTING'),
'inspection' => env('TRELLO_LIST_ID_INSPECTION'),
'packing' => env('TRELLO_LIST_ID_PACKING'),
'ready_to_ship' => env('TRELLO_LIST_ID_READY_TO_SHIP'),
'awaiting_collection' => env('TRELLO_LIST_ID_AWAITING_COLLECTION'),
'in_transit' => env('TRELLO_LIST_ID_IN_TRANSIT'),
'done' => env('TRELLO_LIST_ID_DONE'),
'new_custom_order' => env('TRELLO_LIST_ID_NEW_CUSTOM_ORDER') ?: ($env['TRELLO_LIST_ID_NEW_CUSTOM_ORDER'] ?? null),
'design' => env('TRELLO_LIST_ID_DESIGN') ?: ($env['TRELLO_LIST_ID_DESIGN'] ?? null),
'awaiting_approval' => env('TRELLO_LIST_ID_AWAITING_APPROVAL') ?: ($env['TRELLO_LIST_ID_AWAITING_APPROVAL'] ?? null),
'awaiting_balance' => env('TRELLO_LIST_ID_AWAITING_BALANCE') ?: ($env['TRELLO_LIST_ID_AWAITING_BALANCE'] ?? null),
'ready_for_print' => env('TRELLO_LIST_ID_READY_FOR_PRINT') ?: ($env['TRELLO_LIST_ID_READY_FOR_PRINT'] ?? null),
'printing' => env('TRELLO_LIST_ID_PRINTING') ?: ($env['TRELLO_LIST_ID_PRINTING'] ?? null),
'inspection' => env('TRELLO_LIST_ID_INSPECTION') ?: ($env['TRELLO_LIST_ID_INSPECTION'] ?? null),
'packing' => env('TRELLO_LIST_ID_PACKING') ?: ($env['TRELLO_LIST_ID_PACKING'] ?? null),
'ready_to_ship' => env('TRELLO_LIST_ID_READY_TO_SHIP') ?: ($env['TRELLO_LIST_ID_READY_TO_SHIP'] ?? null),
'awaiting_collection' => env('TRELLO_LIST_ID_AWAITING_COLLECTION') ?: ($env['TRELLO_LIST_ID_AWAITING_COLLECTION'] ?? null),
'in_transit' => env('TRELLO_LIST_ID_IN_TRANSIT') ?: ($env['TRELLO_LIST_ID_IN_TRANSIT'] ?? null),
'done' => env('TRELLO_LIST_ID_DONE') ?: ($env['TRELLO_LIST_ID_DONE'] ?? null),
],
],
];