feat(Deployment): Integrate Ansible deployment via PHP deployment pipeline

- Create AnsibleDeployStage using framework's Process module for secure command execution
- Integrate AnsibleDeployStage into DeploymentPipelineCommands for production deployments
- Add force_deploy flag support in Ansible playbook to override stale locks
- Use PHP deployment module as orchestrator (php console.php deploy:production)
- Fix ErrorAggregationInitializer to use Environment class instead of $_ENV superglobal

Architecture:
- BuildStage → AnsibleDeployStage → HealthCheckStage for production
- Process module provides timeout, error handling, and output capture
- Ansible playbook supports rollback via rollback-git-based.yml
- Zero-downtime deployments with health checks
This commit is contained in:
2025-10-26 14:08:07 +01:00
parent a90263d3be
commit 3b623e7afb
170 changed files with 19888 additions and 575 deletions

View File

@@ -0,0 +1,93 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/../../vendor/autoload.php';
use App\Framework\HttpClient\CurlHttpClient;
use App\Framework\Notification\Channels\Telegram\TelegramClient;
use App\Framework\Notification\Channels\Telegram\TelegramConfig;
use App\Framework\Notification\Channels\Telegram\ValueObjects\{TelegramBotToken, TelegramChatId};
echo "🔷 Telegram Notification Test\n";
echo str_repeat('=', 50) . "\n\n";
try {
// 1. Create Telegram configuration
echo "1⃣ Creating Telegram configuration...\n";
$config = TelegramConfig::createDefault();
echo " ✅ Config created\n";
echo " 🔗 API URL: {$config->getApiUrl()}\n\n";
// 2. Create HTTP client and Telegram client
echo "2⃣ Creating Telegram client...\n";
$httpClient = new CurlHttpClient();
$telegramClient = new TelegramClient($httpClient, $config);
echo " ✅ Client created\n\n";
// 3. Test bot info
echo "3⃣ Testing bot connection (getMe)...\n";
try {
$botInfo = $telegramClient->getMe();
echo " ✅ Bot connected successfully!\n";
echo " 🤖 Bot Name: {$botInfo['first_name']}\n";
echo " 📛 Username: @{$botInfo['username']}\n";
echo " 🆔 Bot ID: {$botInfo['id']}\n\n";
} catch (\Throwable $e) {
echo " ❌ Bot connection failed: {$e->getMessage()}\n\n";
}
// 4. Test chat ID
$testChatId = TelegramChatId::fromString('8240973979');
echo "4⃣ Test recipient: {$testChatId->toString()}\n\n";
// 5. Send text message
echo "5⃣ Sending text message...\n";
try {
$response = $telegramClient->sendMessage(
chatId: $testChatId,
text: "🎉 Test message from Custom PHP Framework!\n\nThis is a test notification via Telegram Bot API.",
parseMode: 'Markdown'
);
echo " ✅ Message sent successfully!\n";
echo " 📨 Message ID: {$response->messageId->toString()}\n\n";
} catch (\Throwable $e) {
echo " ❌ Text message failed: {$e->getMessage()}\n\n";
}
// 6. Send formatted message
echo "6⃣ Sending formatted message with Markdown...\n";
try {
$formattedText = "*Bold Title*\n\n" .
"_Italic text_\n\n" .
"`Code block`\n\n" .
"[Click here](https://example.com)";
$response = $telegramClient->sendMessage(
chatId: $testChatId,
text: $formattedText,
parseMode: 'Markdown'
);
echo " ✅ Formatted message sent!\n";
echo " 📨 Message ID: {$response->messageId->toString()}\n\n";
} catch (\Throwable $e) {
echo " Formatted message skipped: {$e->getMessage()}\n\n";
}
echo "✅ Telegram notification test completed!\n\n";
echo "📝 Notes:\n";
echo " - Create a bot via @BotFather on Telegram\n";
echo " - Get your chat ID by messaging the bot and checking /getUpdates\n";
echo " - Replace YOUR_BOT_TOKEN_HERE with actual bot token\n";
echo " - Replace YOUR_CHAT_ID_HERE with your actual chat ID\n";
echo " - Bot token format: 123456789:ABCdefGHIjklMNOpqrsTUVwxyz\n";
} catch (\Throwable $e) {
echo "\n❌ Test failed: {$e->getMessage()}\n";
echo "Stack trace:\n{$e->getTraceAsString()}\n";
exit(1);
}