dev-master
9999999-dev https://github.com/pontifex/SMSZF2 wrapper for various SMS providers.
BSD-3-Clause
The Requires
- php >=5.3.3
- zendframework/zendframework 2.*
The Development Requires
zf2 sms module
ZF2 wrapper for various SMS providers.
ZF2 wrapper for various SMS providers., (*1)
TODO: 1) Implement next adapters. (If you find this repository useful and would like to contribute new adapters, you are welcome!), (*3)
To add new SMS adapter implement \SMS\Model\Adapter\AdapterInterface (1 method - send())., (*4)
Tested on ZF 2.2.1 and PHP 5.3.3, (*5)
How to use example:, (*6)
Module is available via composer., (*7)
{ "require": { "pontifex/sms": "dev-master" } }
Before you start: - set credentials for chosen adapter (in our case SMSAPI) as shown in sms.config.global.php - be sure you added "SMS" module to application.config.php, (*8)
How to use example:, (*9)
namespace Application\Controller; use Zend\Mvc\Controller\AbstractActionController, Zend\View\Model\ViewModel, SMS\Model\SMS, SMS\Model\Struct; /** * Class IndexController * @package SMS\Controller */ class IndexController extends AbstractActionController implements CountryPrefixConstantsInterface { /** * @return ViewModel */ public function indexAction() { $item1 = new Struct\SMS(); $item1->setTo(new Struct\NumberTo(self::POLAND, '123123123')); $item1->setMessage(new Struct\Message('Hello world #1!')); $item2 = new Struct\SMS(); $item2->setTo(new Struct\NumberTo(self::GERMANY, '321321321')); $item2->setMessage(new Struct\Message('Hello world #2!')); $coll = new Struct\SMSCollection(); $coll->attach($item1); $coll->attach($item2); /** @var SMS $sms */ $sms = $this->getServiceLocator()->get('SMS\Factory\SMSAPITest'); try { $sms->send($coll); } catch (\Exception $e) { // } return new ViewModel(array('result' => $sms->getResult())); } }
If you would like to add eg. log sms feature, the best implement it using preSend, postSend and errorOnSend events (example from Module.php)., (*10)
/** * @param MvcEvent $e */ public function onBootstrap(\Zend\Mvc\MvcEvent $e) { $e->getApplication()->getEventManager()->getSharedManager()->attach( 'SMS\Model\Adapter\AdapterAbstract', 'SMS.postSend', function(\Zend\EventManager\Event $event) { echo 'SMS to number: ' . $event->getParam('to')->getNumber() . ' is sent!<br />'; } ); }
ZF2 wrapper for various SMS providers.
BSD-3-Clause
zf2 sms module