karser/mainsms-bundle
Composer 安装命令:
composer require karser/mainsms-bundle
包简介
Symfony MainSMSBundle
关键字:
README 文档
README
Prerequisites
This version of the bundle requires Symfony 2.1+ and Doctrine ORM 2.2+
Installation
Installation is a quick 3 step process:
- Download KarserMainSMSBundle using composer
- Enable the Bundle
- Configure the KarserMainSMSBundle
Step 1: Download KarserMainSMSBundle using composer
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.
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Karser\MainSMSBundle\KarserMainSMSBundle(), ); }
Step 3: Configure the 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
Usage Steps
Basic usage
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
Schedule the message
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.
统计信息
- 总下载量: 90
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-01-02