Download the PHP package abcsun/laravel-sms without Composer

On this page you can find all versions of the php package abcsun/laravel-sms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-sms

laravel-sms for laravel 5

使用场景

  1. 发送短信验证码。
  2. 发送信息通知短信(如:订单通知,发货通知,上课通知...)。
  3. 特殊情况下用户收不到短信? laravel-sms提倡通过备用代理器机制使用两个及两个以上服务商。

该包特性

  1. 数据库记录/管理短信数据及其发送情况。
  2. 兼容模板短信和内容短信。
  3. 支持短信队列
  4. 备用代理器(服务商)机制。即:如果用一个服务商发送短信失败,将会自动尝试通过预先设置的备用服务商发送。
  5. 集成验证码短信发送/校验模块,分分钟搞定验证码短信发送以及手机号/验证码校验, 从此告别重复写验证码短信发送与校验的历史。
  6. 支持语音验证码,使用方法见特性5。
  7. 集成如下第三方短信服务商,你也可自定义代理器
服务商 模板短信 内容短信 语音验证码 最低消费 最低消费单价
Luosimao no yes yes ¥850(1万条) ¥0.085/条
云片网络 no yes yes ¥55(1千条) ¥0.055/条
容联·云通讯 yes no yes 充值¥500 ¥0.055/条
SUBMAIL yes no no ¥100(1千条) ¥0.100/条
云之讯 yes no yes ¥0.050/条

安装

在项目根目录下运行如下composer命令:

快速上手

1.注册服务提供器

在config/app.php文件中providers数组里加入:

在config/app.php文件中的aliases数组里加入

2.migration生成 & 参数配置

如果你使用的是Luosimao,请在数组'Luosimao'中按照提示填写配置信息

更多的服务商配置就不详说了,请到配置文件中查看并按提示修改相应代理服务商的配置。

3.Enjoy it! 使用Sms模型发送短信

在控制器中发送触发短信,如:

4.常用的语法糖

如果你只使用了默认代理器,即没有开启备用代理器机制。你只需要设置默认代理器的模板ID:

如果你要开启备用代理器机制,那么需要为只支持模板短信默认/备用代理器设置相应模板ID,这样才能保证这些代理器正常使用。可以这样设置:

短信队列

在config/laravel-sms中修改配置

如果你开启了队列,需要运行如下命名监听队列

备用代理器机制

如果用一个服务商发送短信失败(如:欠费、频繁发送、发送次数上限、内容重复...),将会自动尝试通过备用服务商发送。 在config/laravel-sms.php中配置备用代理器

其中agents中如果有多个值,如:A,B,C。 那么当默认代理器发送失败时,会自动启用A代理器,若A代理器发送失败,则会自动启用B,依次类推直到最后一个备用代理器。

验证码短信模块

可以直接访问example.com/sms/info查看该模块是否可用,并可在该页面里观察验证码短信发送数据,方便你进行调试。

1.[浏览器端]请求发送带验证码短信

该包已经封装好浏览器端的jquery/zepto插件,只需要为发送按钮添加扩展方法即可实现发送短信。

注意: 如果你使用Luosimao语音验证码,请在配置文件中'Luosimao'中设置'voiceApikey'。

2.[服务器端]配置短信内容/模板

配置文件: config/laravel-sms.php

如果你使用的是内容短信(如云片网络,Luosimao),则使用或修改'verifySmsContent'的值:

如果你使用模板短信(如云通讯,SubMail),需要到相应代理器中填写模板标示符:

3.[服务器端]合法性验证

用户填写验证码并提交表单到服务器时,在你的控制器中需要验证手机号和验证码是否正确,你只需要加上如下代码即可:

PS:

自助二次开发

1.自定义Model

继承model类(Toplan\Sms\Sms)

修改model类后需要在配置文件中,修改key为'smsModel'的值:

自定义代理器

欢迎贡献更多的代理器,这样就能支持更多第三方服务商的发送接口。请注意命名规范,Foo为代理器(服务商)名称。

配置项加入到src/config/laravel-sms.php中:

在agents目录下添加代理器类(注意类名为FooAgent),并继承Agent抽象类。如果使用到其他api,可以将api文件放入src/lib文件夹中。

至此, 新加代理器成功!

License

MIT


All versions of laravel-sms with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package abcsun/laravel-sms contains the following files

Loading the files please wait ....