serwersms/serwersmsbundle
SerwerSMSBundle is a Symfony bundle for integrating the SerwerSMS API, providing configuration and services to send single or bulk SMS, manage contacts and groups, and handle delivery reports within Symfony applications.
This bundle is a thin Symfony integration around the SerwerSMS.pl API v2 PHP client. Treat it as a legacy integration layer: confirm the bundle supports your Symfony/PHP version before adopting it, and expect to read the underlying client classes rather than rely on extensive bundle documentation.
Minimal setup:
Install with Composer:
composer require serwersms/serwersmsbundle
Register the bundle:
app/AppKernel.php.
$bundles = [
// ...
new SerwerSMS\SerwerSMSBundle\SerwerSMSBundle(),
];
config/bundles.php.
return [
// ...
SerwerSMS\SerwerSMSBundle\SerwerSMSBundle::class => ['all' => true],
];
Configure API credentials. The exact key layout depends on the bundle version, but it follows the normal Symfony bundle pattern:
# config/packages/serwersms.yaml (Symfony 4)
# or app/config/config.yml (Symfony 2/3)
serwer_sms:
username: '%env(SERWERSMS_USERNAME)%'
password: '%env(SERWERSMS_PASSWORD)%'
Discover the actual service ID before writing code:
bin/console debug:container serwer
bin/console debug:container --tag=serwersms
Look for the client service exposed by the bundle, then inject it into a controller, command, or your own service.
First use case: send a single transactional SMS from a Symfony command. Inject the bundle client, call its message-sending API, log the response, and verify delivery separately using the client’s status/check method. Do this in a command before wiring it into user-facing flows so you can validate credentials, sender name, and phone-number formatting safely.
Inject the bundle client, then wrap it. Do not scatter direct client calls through controllers. Create a small application service such as SmsSender that depends on the bundle client, normalizes phone numbers, chooses the sender name, and translates API responses into your domain result.
final class SmsSender
{
public function __construct(private $serwerSmsClient)
{
}
public function send(string $phone, string $text): void
{
$response = $this->serwerSmsClient->messages->send([
'phone' => $phone,
'text' => $text,
'sender' => 'MyApp',
]);
// Map response/error codes to your own exceptions or result object.
}
}
Use it for common SMS workflows:
Keep API calls out of the request cycle when possible. SMS gateways are external dependencies. For non-critical messages, dispatch a Symfony Messenger message or write to an outbox table and process it from a worker. For OTPs, send synchronously but set short HTTP/guzzle timeouts and handle failure explicitly.
Normalize inputs before calling the API. Store phone numbers in E.164 format where possible. Keep sender names in configuration, not hard-coded in multiple services. Validate message length and encoding locally to avoid surprise multi-part SMS costs.
Persist the provider response. Save the external message ID, status, timestamp, recipient, and raw response. This is essential for support, reconciliation, and retry logic.
Test behind an interface. Since the bundle exposes a concrete client, define your own SmsGateway interface and adapt the SerwerSMS client to it. In tests, replace the adapter with a fake. This also makes it easier to migrate away from the bundle later.
serwersms/php-client package and wire it yourself.debug:container and debug:config rather than guessing. If the bundle’s services are private under Symfony 4, inject them via constructor autowiring or define an alias in your own services.yaml.+48 prefix. Validate locally and avoid assuming the API will normalize arbitrary input.How can I help you explore Laravel packages today?