kphoen/sms-sender-bundle
A Symfony bundle that integrates the SMS Sender library, letting PHP applications send text messages through configurable gateways and providers via a simple service-based API.
The first thing to internalize: this is a Symfony2 bundle, deprecated since 2014, and it is a thin DI/config wrapper around the standalone kphoen/sms-sender library. It does nothing you cannot do directly with the library, so the real decision is whether you need the bundle at all. In a Laravel codebase the answer is almost always no — pull the underlying library (or a maintained provider SDK) and skip the bundle entirely. Only reach for the bundle if you are maintaining a legacy Symfony 2.x application that already has it in composer.json.
Minimal steps if you do need it:
composer require kphoen/sms-sender-bundle — expect the resolver to fight you. The package predates PHP 7 type hints and Symfony 3, so pin your PHP platform config and confirm the Symfony FrameworkBundle version constraint before assuming it installs.new KPhoen\SmsSenderBundle\KPhoenSmsSenderBundle() in AppKernel::registerBundles().kphoen_sms_sender: block to app/config/config.yml with your provider name and credentials, and move the secrets into parameters.yml / environment variables immediately.Where to look first, in this order:
DependencyInjection/Configuration.php — the authoritative list of config keys. The README is from 2014 and the config shape drifted across provider versions; trust the tree builder over the docs.Resources/config/services.xml — tells you the exact service ID to inject (typically the bundle ID, e.g. kphoen_sms_sender, aliased to the library's sender interface). Confirm with php app/console debug:container kphoen_sms_sender.ProviderInterface — this is the seam you'll mock in tests and the contract a custom provider must satisfy.First use case: wire it to a single transactional event — an order confirmation or a password-reset OTP — behind your own SmsNotifier service, not directly in a controller. That wrapper is what makes the deprecation survivable: when you swap providers or replace the library, only one class changes.
Wrap, don't inject the bundle service everywhere. Create an application-owned App\Services\SmsNotifier that takes the bundle's sender as a constructor dependency and exposes intent-revealing methods (sendOrderConfirmation($order), sendOtp($user, $code)). This keeps the abandoned API at the edge of your codebase, gives you one place to add logging, templating, and retry policy, and makes the eventual rip-and-replace a one-file diff.
Message construction stays boring. Build the recipient (normalize to E.164 yourself — the library does not reliably do it), the body from a template, and the optional sender/from value. Send, then branch on the returned result rather than assuming success; treat provider exceptions as a first-class outcome, not an edge case.
Move sending off the request cycle. SMS providers are synchronous HTTP calls with p95 latencies that will occasionally blow your response budget. In Symfony, dispatch a domain event and handle it in a listener backed by a queue; in Laravel, the direct analogue is a queued job or a Notification channel. Either way, the controller should enqueue, not send.
Use a console command as your smoke test. A sms:test <number> command that resolves the sender from the container and sends one message is worth more than any unit test for confirming credentials and provider config on a new environment.
Testing: never let a test hit a real provider. Because the bundle just wires the library, mock the sender service in the container (Symfony 2.8-era getMockBuilder / prophesize) or bind a fake ProviderInterface implementation that records messages. In Laravel, bind a fake implementation of your own SmsNotifier interface — this is another argument for the wrapper.
Provider swapping is a config change if you stay within the providers the library supports, and a new class implementing ProviderInterface if you don't. Keep the provider selection in config, not in code, so a staging environment can point at a logging/null provider.
config.yml are a classic Symfony2 leak. Use parameters.yml (gitignored) or environment variables; never commit account_sid/auth_token/API keys. Rotate anything that has been in a repo.app/logs/ is an audit finding. Log the provider, message ID, and a hashed recipient.debug:container <service_id> to confirm the alias, then a --env=dev run with a null/log provider to isolate "is it config or is it the provider?" Swap credentials for a known-good pair before assuming code is at fault.ProviderInterface for a provider the library doesn't cover, then alias that class to the sender's provider argument via a small compiler pass or a service override. If you find yourself patching the bundle, stop — fork the service definition into your own services.xml and drop the dependency.How can I help you explore Laravel packages today?