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:
90
tests/debug/test-whatsapp-notification.php
Normal file
90
tests/debug/test-whatsapp-notification.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
use App\Framework\Core\ValueObjects\PhoneNumber;
|
||||
use App\Framework\HttpClient\CurlHttpClient;
|
||||
use App\Framework\Notification\Channels\WhatsApp\WhatsAppClient;
|
||||
use App\Framework\Notification\Channels\WhatsApp\WhatsAppConfig;
|
||||
use App\Framework\Notification\Channels\WhatsApp\ValueObjects\WhatsAppTemplateId;
|
||||
|
||||
echo "🔷 WhatsApp Notification Test\n";
|
||||
echo str_repeat('=', 50) . "\n\n";
|
||||
|
||||
try {
|
||||
// 1. Create WhatsApp configuration
|
||||
echo "1️⃣ Creating WhatsApp configuration...\n";
|
||||
$config = WhatsAppConfig::createDefault();
|
||||
echo " ✅ Config created\n";
|
||||
echo " 📞 Phone Number ID: {$config->phoneNumberId}\n";
|
||||
echo " 🔗 API URL: {$config->getApiUrl()}\n\n";
|
||||
|
||||
// 2. Create HTTP client and WhatsApp client
|
||||
echo "2️⃣ Creating WhatsApp client...\n";
|
||||
$httpClient = new CurlHttpClient();
|
||||
$whatsappClient = new WhatsAppClient($httpClient, $config);
|
||||
echo " ✅ Client created\n\n";
|
||||
|
||||
// 3. Test phone number
|
||||
$testPhoneNumber = PhoneNumber::fromString('+4917941122213');
|
||||
echo "3️⃣ Test recipient: {$testPhoneNumber->toDisplayFormat()}\n\n";
|
||||
|
||||
// 4. Send text message
|
||||
echo "4️⃣ Sending text message...\n";
|
||||
try {
|
||||
$response = $whatsappClient->sendTextMessage(
|
||||
to: $testPhoneNumber,
|
||||
message: "🎉 Test message from Custom PHP Framework!\n\nThis is a test notification via WhatsApp Business API."
|
||||
);
|
||||
|
||||
echo " ✅ Message sent successfully!\n";
|
||||
echo " 📨 Message ID: {$response->messageId->toString()}\n\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo " ❌ Text message failed: {$e->getMessage()}\n\n";
|
||||
}
|
||||
|
||||
// 5. Send template message (hello_world template)
|
||||
echo "5️⃣ Sending template message...\n";
|
||||
try {
|
||||
$templateResponse = $whatsappClient->sendTemplateMessage(
|
||||
to: $testPhoneNumber,
|
||||
templateId: WhatsAppTemplateId::fromString('hello_world'),
|
||||
languageCode: 'en_US'
|
||||
);
|
||||
|
||||
echo " ✅ Template message sent successfully!\n";
|
||||
echo " 📨 Message ID: {$templateResponse->messageId->toString()}\n\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo " ❌ Template message failed: {$e->getMessage()}\n\n";
|
||||
}
|
||||
|
||||
// 6. Test with parameters (if you have a template with parameters)
|
||||
echo "6️⃣ Sending template with parameters...\n";
|
||||
try {
|
||||
$paramResponse = $whatsappClient->sendTemplateMessage(
|
||||
to: $testPhoneNumber,
|
||||
templateId: WhatsAppTemplateId::fromString('sample_template'), // Replace with your template
|
||||
languageCode: 'en',
|
||||
parameters: ['John Doe', '2024-12-20']
|
||||
);
|
||||
|
||||
echo " ✅ Parametrized template sent!\n";
|
||||
echo " 📨 Message ID: {$paramResponse->messageId->toString()}\n\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo " ℹ️ Parametrized template skipped: {$e->getMessage()}\n\n";
|
||||
}
|
||||
|
||||
echo "✅ WhatsApp notification test completed!\n\n";
|
||||
|
||||
echo "📝 Notes:\n";
|
||||
echo " - Replace test phone number with your WhatsApp number\n";
|
||||
echo " - Phone number must be in E.164 format (+country code + number)\n";
|
||||
echo " - Make sure the number is registered with your WhatsApp Business account\n";
|
||||
echo " - Template names must be approved in your WhatsApp Business account\n";
|
||||
} catch (\Throwable $e) {
|
||||
echo "\n❌ Test failed: {$e->getMessage()}\n";
|
||||
echo "Stack trace:\n{$e->getTraceAsString()}\n";
|
||||
exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user