This version of the bundle requires Symfony 2.1+ and Doctrine ORM 2.2+
Installation is a quick 3 step process:
- Download KarserMainSMSBundle using composer
- Enable the Bundle
- Configure the KarserMainSMSBundle
Add KarserMainSMSBundle in your composer.json:
{
"require": {
"karser/mainsms-bundle": "dev-master"
}
}
Now tell composer to download the bundle by running the command:
$ php ./composer.phar update
Composer will install the bundle to your project's vendor/karser
directory.
Enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Karser\MainSMSBundle\KarserMainSMSBundle(),
);
}
Add the following configuration to your config.yml
file according to which type
of datastore you are using.
# app/config/config.yml
karser_main_sms:
project: "%main_sms_project%"
key: "%main_sms_key%"
use_ssl: "%main_sms_use_ssl%"
test_mode: "%main_sms_test_mode%"
# app/config/parameters.yml
parameters:
main_sms_project: ~ # project name
main_sms_key: ~ # sms key
main_sms_use_ssl: ~ # true or false
main_sms_test_mode: ~ # true or false
If you going to store messages in the database, don't forget to update your schema:
app/console doctrine:schema:update
You can send message directly:
$MainSMSModel = $this->get('karser.main_sms.model');
//or use getter trait
use \Karser\MainSMSBundle\Model\Getter;
$MainSMSModel = $this->getMainSmsModel($this->container);
//send message
$MainSMSModel->messageSend($number, $message, $sender);
You can check the balance by cli command:
$ app/console mainsms:balance
> Balance is 6.45
Ensure that doctrine automapping is enabled:
doctrine:
orm:
auto_mapping: true
It maps the message to SMSTask entity and stores to the database.
$MainSMSManager = $this->get('karser.main_sms.manager');
//or use getter trait
use \Karser\MainSMSBundle\Manager\Getter;
$MainSMSManager = $this->getMainSmsManager($this->container);
//schedule message
$MainSMSManager->schedule($number, $message, $sender);
You can send it later by cli command:
$ app/console mainsms:send
> Balance is 6.45
> Messages to send 1
.
Done.