|
1 |
| - |
2 | 1 | # scaytrase/symfony-sms-delivery-bundle
|
3 |
| -[](https://packagist.org/packages/scaytrase/symfony-sms-interface) [](https://packagist.org/packages/scaytrase/symfony-sms-interface) [](https://packagist.org/packages/scaytrase/symfony-sms-interface) [](https://packagist.org/packages/scaytrase/symfony-sms-interface) |
| 2 | +[](https://packagist.org/packages/scaytrase/symfony-sms-interface) |
| 3 | +[](https://packagist.org/packages/scaytrase/symfony-sms-interface) |
| 4 | +[](https://packagist.org/packages/scaytrase/symfony-sms-interface) |
| 5 | +[](https://packagist.org/packages/scaytrase/symfony-sms-interface) |
4 | 6 |
|
5 | 7 | [](https://packagist.org/packages/scaytrase/symfony-sms-interface)
|
6 | 8 | [](https://packagist.org/packages/scaytrase/symfony-sms-interface)
|
7 | 9 |
|
8 |
| -This Symfony2 bundle provides basic service for sending short messages. This bundle does not provide you any finished implementation for communicating the SMS gateway. To use it you have use some transport implementation or implemenent a transport on your own. See [usage section](#Usage) for known implementations |
| 10 | +This Symfony bundle provides basic service for sending short messages. This bundle does not provide you any finished |
| 11 | +implementation for communicating the SMS gateway. To use it you have use some transport implementation or |
| 12 | +implement a transport on your own. See [usage section](#Usage) for known implementations |
9 | 13 |
|
10 | 14 | ## Features
|
11 | 15 |
|
@@ -47,22 +51,50 @@ Below is the configuration example and their default values
|
47 | 51 |
|
48 | 52 | ```yaml
|
49 | 53 | sms_delivery:
|
| 54 | + spool: sms_delivery.spool.instant |
50 | 55 | transport: sms_delivery.dummy_sender # @id of the transport service
|
51 |
| - disable_delivery: false # disables actual delivery making every send return successful result. use profiler to get message details |
52 |
| - delivery_recipient: null # when not null - sends every message to the specified recipient, ignoring actual recipient of the message. |
| 56 | + disable_delivery: false # disable delivery overrides spool with disabled spool |
| 57 | + delivery_recipient: null # delivery recipient overrides recipient when sending |
53 | 58 | ```
|
54 | 59 |
|
55 | 60 | ## Usage
|
56 | 61 |
|
57 |
| -To use this interface you must create a message class implementing ``ShortMessageInterface`` and implement a transport that delivers your message to end point sms gateway. You can refer my [WebSMS](https://github.com/scaytrase/symfony-websms-bundle) gateway implementation as a reference. |
| 62 | +To use this interface you must create a message class implementing ``ShortMessageInterface`` and create the implementation of the |
| 63 | +``TransportInterface`` that delivers your message to end point sms gateway. |
| 64 | +You can refer my [WebSMS](https://github.com/scaytrase/symfony-websms-bundle) gateway implementation as a reference. |
58 | 65 |
|
59 | 66 |
|
60 | 67 | ### Example
|
61 | 68 |
|
62 |
| -```php |
| 69 | +```php |
| 70 | +class MyMessage implements ShortMessageInterface { /*...*/ } |
| 71 | + |
| 72 | +class SmsController extends Controller { |
| 73 | + |
63 | 74 | public function sendSmsAction(){
|
64 |
| - $message = new YourMessage('5552368','Help!') |
65 |
| - $result = $this->get('sms_delivery.sender')->send($message); |
66 |
| - return new Response('Delivery '. $result ? 'successful' ; 'failed'); |
| 75 | + $message = new MyMessage('5552368','Help!') |
| 76 | + $sender = $this->get('sms_delivery.sender'); |
| 77 | + $sender->spoolMessage($message); |
| 78 | + $result = $sender->flush(); |
| 79 | + return new Response('Delivery '. $result ? 'successful' : 'failed'); |
67 | 80 | }
|
68 | 81 | ```
|
| 82 | + |
| 83 | + |
| 84 | +### Standalone usage |
| 85 | + |
| 86 | +Despite of the fact that this library is designed as Symfony bundle it could be used as standalone library for sending |
| 87 | +short messages. You should just instantiate sender service on your own. |
| 88 | + |
| 89 | +```php |
| 90 | + |
| 91 | + class MyProviderSmsTransport implements TransportInterface { /*...*/ } |
| 92 | + |
| 93 | + class MyMessage implements ShortMessageInterface { /*...*/ } |
| 94 | + |
| 95 | + $transport = new MyProviderSmsTransport(); |
| 96 | + $sender = new MessageDeliveryService($transport); |
| 97 | + $sender->spoolMessage(new MyMessage('Message body')); |
| 98 | + $sender->flush(); // Default InstantSpool does not actually needs flushing but you can use another spool instead |
| 99 | + |
| 100 | +``` |
0 commit comments