signalads/php
PHP client for the SignalAds REST API to send SMS messages. Supports single and bulk sends, pattern-based SMS, and structured error handling via ApiException/HttpException. Install with Composer and authenticate using your API key from the SignalAds panel.
HttpClient) or Guzzle integration patterns.message_id, status) can trigger Laravel events (e.g., SmsSent, SmsFailed) for async processing (e.g., logging, notifications).SignalAdsService) with API key binding via .env.Sms::send()) for cleaner syntax.SignalAdsV1Api) for backward compatibility.ApiException, HttpException) are clear but may need extension for Laravel’s logging (e.g., Log::error($e->getMessage()))..env for key storage.GetCredit() calls)?$this->app->singleton(SignalAdsApi::class, function ($app) {
return new SignalAdsApi(config('services.signalads.key'));
});
Sms facade for fluent syntax:
use Facades\Sms;
Sms::send('12345', '09123456789', 'Hello');
SendGroup in a job for async bulk sends:
SendSmsJob::dispatch($sender, $receptors, $message);
SignalAdsApi in tests using Laravel’s MockHttp or PHPUnit’s getMockBuilder.$mock = Mockery::mock(SignalAdsApi::class)->makePartial();
$mock->shouldReceive('Send')->andReturn(['data' => ['message_id' => '123']]);
config/services.php:
'signalads' => [
'key' => env('SIGNALADS_API_KEY'),
],
$this->app->bind(SignalAdsApi::class, function ($app) {
return new SignalAdsApi(config('services.signalads.key'));
});
app/Services/SmsService.php) to abstract the client.class SmsService {
public function __construct(private SignalAdsApi $client) {}
public function send(string $sender, string $receptor, string $message) {
return $this->client->Send($sender, $receptor, $message);
}
}
ApiException to Sentry).HttpClient if configured.message_id) may require a sms_logs table.SignalAds namespace vs. other packages).^1.0) for Composer.version parameter to the client.README.md in the Laravel project detailing:
class LaravelApiException extends ApiException {
public function __construct(string $message, array $context = []) {
parent::__construct($message);
$this->context = $context;
}
}
catch (ApiException $e) {
Log::error($e->getMessage(), ['context' => $e->getContext()]);
}
$client = new SignalAdsApi($key, [
'debug' => env('APP_DEBUG'),
]);
dumpResponse() method in the client for troubleshooting.SendSmsJob::dispatch($sender, $receptors, $message)
->onQueue('sms')
->delay(now()->addSeconds(10)); // Throttle if needed
spatie/laravel-queue-retries).semaphore package to limit parallel jobs.$semaphore = app(Semaphore::class);
$semaphore->increment('sms_api_calls');
// ... API call ...
$semaphore->decrement('sms_api_calls');
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| API Key invalid/expired | All SMS fails | Validate key on boot; implement key rotation. |
| Network timeout | Blocked requests | Use Laravel queues with retries. |
| SignalAds API downtime | SMS delivery halted | Fallback to a secondary SMS provider (e.g., via a SmsGateway interface). |
| Rate limit exceeded | Throttled requests | Implement queue delays; use retry-after headers. |
| Invalid phone numbers | Failed sends | Validate numbers via a PhoneValidator service before sending. |
| Database connection issues | Logging fails | Use a fallback logger (e.g., file-based). |
How can I help you explore Laravel packages today?