karser / mainsms-bundle
Symfony MainSMSBundle
dev-master
2014-02-08 11:54 UTC
Requires
- php: >=5.3.2
- karser/sms-bundle: dev-master
- symfony/framework-bundle: >=2.1,<3.0
This package is auto-updated.
Last update: 2024-09-20 07:00:02 UTC
README
先决条件
本版本的bundle需要Symfony 2.1+和Doctrine ORM 2.2+
安装
安装是一个快速的三步过程
- 使用composer下载KarserMainSMSBundle
- 启用Bundle
- 配置KarserMainSMSBundle
第一步:使用composer下载KarserMainSMSBundle
在您的composer.json中添加KarserMainSMSBundle
{ "require": { "karser/mainsms-bundle": "dev-master" } }
现在运行以下命令让composer下载bundle
$ php ./composer.phar update
Composer会将bundle安装到您的项目目录的vendor/karser
第二步:启用bundle
在kernel中启用bundle
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Karser\MainSMSBundle\KarserMainSMSBundle(), ); }
第三步:配置KarserMainSMSBundle
根据您使用的存储类型,将以下配置添加到您的config.yml
文件中。
# 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
如果您打算在数据库中存储消息,请不要忘记更新您的模式
app/console doctrine:schema:update
使用步骤
基本使用
您可以直接发送消息
$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);
您可以通过cli命令检查余额
$ app/console mainsms:balance
> Balance is 6.45
安排消息
确保doctrine自动映射已启用
doctrine: orm: auto_mapping: true
它将消息映射到SMSTask实体并存储到数据库中。
$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);
您可以通过cli命令稍后发送它
$ app/console mainsms:send
> Balance is 6.45
> Messages to send 1
.
Done.