Download the PHP package zfegg/sms-sender without Composer

On this page you can find all versions of the php package zfegg/sms-sender. 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 sms-sender

短信发送抽象接口

GitHub Actions: Run tests Coverage Status Coverage Status Latest Stable Version Total Downloads License PHP Version Require

抽象常用短信业务:

  1. 实现短信的限制发送(60s 内限制发送1次,1天上限发送10次)
  2. 短信验证码生成与验证功能

Installation / 安装

使用 Composer 安装

$ composer require zfegg/sms-sender

Interfaces / 接口说明

Usage / 使用

基本使用示例代码:

示例代码

在 Expressive 中使用:

config/application.php 中添加模块加载.

return array(
    'modules' => array(
        //... Your modules
        'Zfegg/SmsSender'
    ),
);

添加短信发送配置 module.config.php


return [
    'dependencies' => [
        'factories' => [
            ProviderInterface::class => YourSmsProviderFactory::class,
        ],
    ]
    'zfegg' => [
        LimitSender::class => [
            'provider' => ProviderInterface::class, // 设置短信商服务名. (可选), 默认 `ProviderInterface::class`
            'cache' => CacheInterface::class, // 设置缓存服务名 (可选), 默认 `CacheInterface::class`
            'day_send_times' => 10, // 设置每天发送次数上限 (可选), 默认10
            'waiting_time' => 60, //设置每次发送等待时长 (可选), 默认60s
        ],
        PostSmsCaptchaHandler::class  => [
            'types' => [
               'register' => 'Register captcha code: {code}',
               'login' => 'Login captcha code: {code}',
            ]
        ],
    ]
];

控制器使用:


//发送验证码
$app->post('/api/send-sms-captcha', PostSmsCaptchaHandler::class);

//业务验证码验证
$app->post('/register', [
  function ($req, $handler) {

    //配置验证器
    $inputFilter = (new \Laminas\InputFilter\Factory)->create([
        [
            'name' => 'captcha',
            'validators' => [
                [
                    'name' => SmsCode::class,
                    'options' => [
                        'inputName' => 'phone',
                    ]
                ]
            ]
        ],
        [
            'name' => 'phone',
            'validators' => [
                [
                    'name' => 'PhoneNumber',
                ]
            ]
        ],
    ])

    if (! $inputFilter->isValid()) {
        //验证失败响应
        return new JsonResponse(['messages' => $inputFilter->getMessages()], 403);
    }

    //验证成功继续注册
    return $handler->handle($req);
  },
  YourRegisterHandler::class,
])

All versions of sms-sender with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
psr/simple-cache Version ^1.0 | ^2.0 | ^3.0
psr/log Version ^1.0 | ^2.0 | ^3.0
psr/event-dispatcher Version ^1.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 zfegg/sms-sender contains the following files

Loading the files please wait ....