PHPackages                             chenzi/laravel-mns-driver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. chenzi/laravel-mns-driver

ActiveLibrary[Queues &amp; Workers](/categories/queues)

chenzi/laravel-mns-driver
=========================

Aliyun MNS Queue Driver For Laravel

17PHP

Since May 23Pushed 8y ago1 watchersCompare

[ Source](https://github.com/chenzi/laravel-mns-driver)[ Packagist](https://packagist.org/packages/chenzi/laravel-mns-driver)[ RSS](/packages/chenzi-laravel-mns-driver/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Aliyun MNS Queue Driver For Laravel
===================================

[](#aliyun-mns-queue-driver-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ba8132779bffe76ee480bdd4a276f459fe8aa312fe373187f8b0c24e29b6e415/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368656e7a692f6c61726176656c2d6d6e732d6472697665722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chenzi/laravel-mns-driver)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/3e7161c8ef2bca1a0a8c802eee18586be086695218eed7f6c08e21acfe714bc2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368656e7a692f6c61726176656c2d6d6e732d6472697665722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chenzi/laravel-mns-driver)

Install
-------

[](#install)

Via Composer

```
$ composer require chenzi/laravel-mns-driver
```

Config
------

[](#config)

Add following service providers into your providers array in `config/app.php`

```
Chenzi\LaravelMNS\LaravelMNSServiceProvider::class
```

Edit your `config/queue.php`, add `mns` connection

```
'mns'        => [
    'sms'=> [
        'driver'       => 'sms',
        'key'          => env('QUEUE_MNS_ACCESS_KEY'),
        'secret'       => env('QUEUE_MNS_SECRET_KEY'),
        'endpoint'     => env('QUEUE_MNS_ENDPOINT'),
        'queue'        => env('QUEUE_NAME'),
        'wait_seconds' => 30,
    ],
    'email'=> [
        'driver'       => 'email',
        'key'          => env('QUEUE_MNS_ACCESS_KEY'),
        'secret'       => env('QUEUE_MNS_SECRET_KEY'),
        'endpoint'     => env('QUEUE_MNS_ENDPOINT'),
        'queue'        => env('QUEUE_NAME'),
        'wait_seconds' => 30,
    ]
]
```

About [wait\_seconds](https://help.aliyun.com/document_detail/35136.html)

Edit your `.env` file

```
QUEUE_DRIVER=mns
QUEUE_NAME=foobar-local
QUEUE_MNS_ACCESS_KEY=your_acccess_key
QUEUE_MNS_SECRET_KEY=your_secret_key
QUEUE_MNS_ENDPOINT=http://12345678910.mns.cn-hangzhou.aliyuncs.com/
```

You should update `QUEUE_MNS_ENDPOINT` to `internal endpoint` in production mode

Usage
-----

[](#usage)

First create a queue and get queue endpoint at [Aliyun MNS Console](https://mns.console.aliyun.com/)

Then update `MNS_ENDPOINT` in `.env`

Push a test message to queue

```
Queue::push(function($job){
	/**
	 * Your statments go here
	 */
	$job->delete();
});
```

You also can custom request data format add mns queue with other program

```
return json_encode( [
    'displayName' => 'App\Jobs\SendSms',
    'job'         => 'App\Jobs\SendSms',
    'maxTries'    => null,
    'timeout'     => null,
    'data'        => [],
] );
```

Create queue work, run command in terminal

```
$ php artisan queue:mns:work sms
```

Commands
--------

[](#commands)

Flush MNS messages on Aliyun

```
$ php artisan queue:mns:flush
```

Job handle
----------

[](#job-handle)

```
class SendSms implements ShouldQueue
{
    ...

    public function handle(ReceiveMessageResponse $job){
        $messageId = $job->getMessageId();
        $messageBody = $job->getMessageBody();

        //TODO do some thing...
    }

    ...
}
```

Security
--------

[](#security)

Create RAM access control at [Aliyun RAM Console](https://ram.console.aliyun.com)

1. Create a custom policy such as `AliyunMNSFullAccessFoobar`

    ```
    {
      "Version": "1",
      "Statement": [
    	{
    	  "Action": "mns:*",
    	  "Resource": [
    		"acs:mns:*:*:*/foobar-local",
    		"acs:mns:*:*:*/foobar-sandbox",
    		"acs:mns:*:*:*/foobar-production"
    	  ],
    	  "Effect": "Allow"
    	}
      ]
    }

    ```
2. Create a user for you app such as `foobar`
3. Assign the policy `AliyunMNSFullAccessFoobar` to the user `foobar`
4. Create and get the `AccessKeyId` and `AccessKeySecret` for user `foorbar`
5. update `QUEUE_MNS_ACCESS_KEY` and `QUEUE_MNS_ACCESS_SECRET` in `.env`

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Credits
-------

[](#credits)

- [Loki Else](https://github.com/chenzi)
- [abrahamgreyson](https://github.com/abrahamgreyson/laravel-mns)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b60b9b9c264083d6902ccb16a1392f9cee7dd691af7e807dc2a2121328f0f96?d=identicon)[chenzi](/maintainers/chenzi)

---

Top Contributors

[![chenzi](https://avatars.githubusercontent.com/u/5486633?v=4)](https://github.com/chenzi "chenzi (9 commits)")

---

Tags

aliyunlaravel

### Embed Badge

![Health badge](/badges/chenzi-laravel-mns-driver/health.svg)

```
[![Health](https://phpackages.com/badges/chenzi-laravel-mns-driver/health.svg)](https://phpackages.com/packages/chenzi-laravel-mns-driver)
```

###  Alternatives

[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.3M26](/packages/league-geotools)[amphp/parser

A generator parser to make streaming parsers simple.

14952.8M16](/packages/amphp-parser)[amphp/serialization

Serialization tools for IPC and data storage in PHP.

13451.1M18](/packages/amphp-serialization)[enqueue/enqueue

Message Queue Library

19820.0M56](/packages/enqueue-enqueue)[deliciousbrains/wp-background-processing

WP Background Processing can be used to fire off non-blocking asynchronous requests or as a background processing tool, allowing you to queue tasks.

1.1k409.8k6](/packages/deliciousbrains-wp-background-processing)[react/async

Async utilities and fibers for ReactPHP

2238.8M171](/packages/react-async)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
